Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more test for OpenAPI Specification v3.1 #2353

Merged
merged 1 commit into from
Oct 15, 2023

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants