Skip to content
6 changes: 6 additions & 0 deletions .changeset/oas32-media-type-description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@redocly/openapi-core': patch
'@redocly/cli': patch
---

Added the `description` field of the Media Type Object, which OpenAPI 3.2.1 defines, so that `lint` no longer reports it in OpenAPI 3.2 descriptions.
Comment thread
JLekawa marked this conversation as resolved.
Resolved
5 changes: 5 additions & 0 deletions packages/core/src/types/oas3_2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,11 @@ const MediaType: NodeType = {
...Oas3_1Types.MediaType,
properties: {
...Oas3_1Types.MediaType.properties,
description: {
type: 'string',
description:
'An optional description for the media type. CommonMark syntax MAY be used for rich text representation.',
},
itemSchema: 'Schema',
prefixEncoding: listOf('Encoding', {
description:
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/lint/oas3.2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ paths:
required: true
content:
application/json:
description: Should allow a description in a Media Type Object (OpenAPI 3.2.1)
schema:
type: object
properties:
Expand Down
132 changes: 66 additions & 66 deletions tests/e2e/lint/oas3.2/snapshot.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,44 +102,44 @@ Property `wrong` is not expected here.
Error was generated by the struct rule.


[8] openapi.yaml:156:9 at #/components/schemas/MyResponseType/discriminator/wrong
[8] openapi.yaml:157:9 at #/components/schemas/MyResponseType/discriminator/wrong

Property `wrong` is not expected here.

154 | propertyName: petType
155 | defaultMapping: OtherPet # Should be allowed
156 | wrong: Should catch a wrong field in discriminator!
155 | propertyName: petType
156 | defaultMapping: OtherPet # Should be allowed
157 | wrong: Should catch a wrong field in discriminator!
| ^^^^^
157 | Lizard:
158 | type: object
158 | Lizard:
159 | type: object

Error was generated by the struct rule.


[9] openapi.yaml:132:11 at #/components/securitySchemes/petstore_auth/flows/implicit/wrong
[9] openapi.yaml:133:11 at #/components/securitySchemes/petstore_auth/flows/implicit/wrong

Property `wrong` is not expected here.

130 | implicit:
131 | authorizationUrl: https://example.org/api/oauth/dialog
132 | wrong: Should catch wrong prop in oauth2 flows!
131 | implicit:
132 | authorizationUrl: https://example.org/api/oauth/dialog
133 | wrong: Should catch wrong prop in oauth2 flows!
| ^^^^^
133 | scopes:
134 | write:pets: modify pets in your account
134 | scopes:
135 | write:pets: modify pets in your account

Error was generated by the struct rule.


[10] openapi.yaml:144:9 at #/components/securitySchemes/device_auth/flows/deviceAuthorization
[10] openapi.yaml:145:9 at #/components/securitySchemes/device_auth/flows/deviceAuthorization

The field `scopes` must be present on this level.

142 | type: oauth2
143 | flows:
144 | deviceAuthorization:
143 | type: oauth2
144 | flows:
145 | deviceAuthorization:
| ^^^^^^^^^^^^^^^^^^^
145 | # scopes: Scopes are required in deviceAuthorization!
146 | deviceAuthorizationUrl: http://localhost
146 | # scopes: Scopes are required in deviceAuthorization!
147 | deviceAuthorizationUrl: http://localhost

Error was generated by the struct rule.

Expand Down Expand Up @@ -207,16 +207,16 @@ Warning was generated by the operation-operationId rule.
Reference: https://redocly.com/docs/cli/rules/oas/operation-operationId


[15] openapi.yaml:65:7 at #/paths/~1products/query/responses
[15] openapi.yaml:66:7 at #/paths/~1products/query/responses

Operation must have at least one `4XX` response.

63 | items:
64 | type: string
65 | responses:
64 | items:
65 | type: string
66 | responses:
| ^^^^^^^^^
66 | '200':
67 | description: Search results
67 | '200':
68 | description: Search results

Warning was generated by the operation-4xx-response rule.

Expand All @@ -239,112 +239,112 @@ Warning was generated by the operation-operationId rule.
Reference: https://redocly.com/docs/cli/rules/oas/operation-operationId


[17] openapi.yaml:70:5 at #/paths/~1stream/get/operationId
[17] openapi.yaml:71:5 at #/paths/~1stream/get/operationId

Operation object should contain `operationId` field.

68 | summary: Should allow summary in responses
69 | /stream:
70 | get:
69 | summary: Should allow summary in responses
70 | /stream:
71 | get:
| ^^^
71 | summary: Stream
72 | responses:
72 | summary: Stream
73 | responses:

Warning was generated by the operation-operationId rule.

Reference: https://redocly.com/docs/cli/rules/oas/operation-operationId


[18] openapi.yaml:72:7 at #/paths/~1stream/get/responses
[18] openapi.yaml:73:7 at #/paths/~1stream/get/responses

Operation must have at least one `4XX` response.

70 | get:
71 | summary: Stream
72 | responses:
71 | get:
72 | summary: Stream
73 | responses:
| ^^^^^^^^^
73 | 200:
74 | description: Stream of updates
74 | 200:
75 | description: Stream of updates

Warning was generated by the operation-4xx-response rule.

Reference: https://redocly.com/docs/cli/rules/oas/operation-4xx-response


[19] openapi.yaml:83:5 at #/paths/~1thing/get/operationId
[19] openapi.yaml:84:5 at #/paths/~1thing/get/operationId

Operation object should contain `operationId` field.

81 | data: { type: object }
82 | /thing:
83 | get:
82 | data: { type: object }
83 | /thing:
84 | get:
| ^^^
84 | summary: a sample api
85 | responses:
85 | summary: a sample api
86 | responses:

Warning was generated by the operation-operationId rule.

Reference: https://redocly.com/docs/cli/rules/oas/operation-operationId


[20] openapi.yaml:85:7 at #/paths/~1thing/get/responses
[20] openapi.yaml:86:7 at #/paths/~1thing/get/responses

Operation must have at least one `4XX` response.

83 | get:
84 | summary: a sample api
85 | responses:
84 | get:
85 | summary: a sample api
86 | responses:
| ^^^^^^^^^
86 | '200':
87 | description: OK
87 | '200':
88 | description: OK

Warning was generated by the operation-4xx-response rule.

Reference: https://redocly.com/docs/cli/rules/oas/operation-4xx-response


[21] openapi.yaml:149:5 at #/components/schemas/MyResponseType
[21] openapi.yaml:150:5 at #/components/schemas/MyResponseType

Component: "MyResponseType" is never used.

147 | tokenUrl: http://localhost
148 | schemas:
149 | MyResponseType:
148 | tokenUrl: http://localhost
149 | schemas:
150 | MyResponseType:
| ^^^^^^^^^^^^^^
150 | oneOf:
151 | - $ref: '#/components/schemas/Lizard'
151 | oneOf:
152 | - $ref: '#/components/schemas/Lizard'

Warning was generated by the no-unused-components rule.

Reference: https://redocly.com/docs/cli/rules/oas/no-unused-components


[22] openapi.yaml:125:5 at #/components/securitySchemes/petstore_auth
[22] openapi.yaml:126:5 at #/components/securitySchemes/petstore_auth

Security scheme: "petstore_auth" is never used.

123 | components:
124 | securitySchemes:
125 | petstore_auth:
124 | components:
125 | securitySchemes:
126 | petstore_auth:
| ^^^^^^^^^^^^^
126 | type: oauth2
127 | deprecated: true # Should allow deprecation
127 | type: oauth2
128 | deprecated: true # Should allow deprecation

Warning was generated by the no-unused-components rule.

Reference: https://redocly.com/docs/cli/rules/oas/no-unused-components


[23] openapi.yaml:136:5 at #/components/securitySchemes/api_key
[23] openapi.yaml:137:5 at #/components/securitySchemes/api_key

Security scheme: "api_key" is never used.

134 | write:pets: modify pets in your account
135 | read:pets: read your pets
136 | api_key:
135 | write:pets: modify pets in your account
136 | read:pets: read your pets
137 | api_key:
| ^^^^^^^
137 | type: apiKey
138 | in: header
138 | type: apiKey
139 | in: header

Warning was generated by the no-unused-components rule.

Expand Down
Loading