Skip to content

Conversation

@xiaoxiangmoe
Copy link
Contributor

No description provided.

Copy link
Contributor

@JohnNiang JohnNiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, schema type is missing here.

},
"components": {
"schemas": {
"ExamplesResponse": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"ExamplesResponse": {
"ExamplesResponse": {
"type": "object",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JohnNiang It seems that the current unit test also not include "type": "object"

"ExamplesResponse": {
"properties": {
"name": {
"type": "string",
"description": "name",
"examples": [
"name"
]
},
"subject": {
"type": "string",
"description": "subject",
"example":"Hello",
"examples": [
"Hello",
"World"
]
}
},
"required": [
"name",
"subject"
]
}

Copy link
Contributor Author

@xiaoxiangmoe xiaoxiangmoe Aug 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See here: https://spec.openapis.org/oas/v3.1.0#data-types

Data types in the OAS are based on the types supported by the JSON Schema Specification Draft 2020-12.

In JSON Schema Specification Draft 2020-12, "type" field is optional, so this is valid JSON schema.

And the api-gen is done by swagger-core. We can advise swagger-core to provide "type": "object".

@xiaoxiangmoe
Copy link
Contributor Author

@uc4w6c Can you review it?

@uc4w6c uc4w6c requested a review from bnasslahsen September 16, 2023 05:43
@uc4w6c
Copy link
Collaborator

uc4w6c commented Sep 16, 2023

@xiaoxiangmoe
Sorry for the late confirmation.
Since I don't have merge privileges, I requested bnasslahsen to be a reviewer.

I thought it might be better to combine it with the test code below.
https://github.com/springdoc/springdoc-openapi/tree/main/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app7

@bnasslahsen
Copy link
Collaborator

@xiaoxiangmoe,

Thank you for your contribution to the project.

@bnasslahsen bnasslahsen merged commit 35e2c82 into springdoc:main Oct 15, 2023
mpleine pushed a commit to mpleine/springdoc-openapi that referenced this pull request May 17, 2025
Add more test for OpenAPI Specification v3.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants