-
Notifications
You must be signed in to change notification settings - Fork 582
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
Combine with MicroProfile OpenAPI: Example of date-time in Schema can not display this format "YYYY-MM-DDTHH:MM:SSZ", will report "OrderedMap" or this "YYYY-MM-DDTHH:MM:SS.MSZ" format #21737
Comments
InvestigationI reproduced the problem with a test data class which looks like this: public class TestData {
@Schema(name = "created_at", format = "date-time")
public String createdAt;
@Schema(name = "last_updated_at", format = "date-time", example = "2018-03-20T09:12:28Z")
public String lastUpdated;
@Schema(name = "started_at", format = "string", example = "2018-03-20T09:12:28Z")
public String startedAt;
} From what I can see, the produced OpenAPI document at schemas:
TestData:
type: object
properties:
created_at:
type: string
format: date-time
last_updated_at:
type: string
format: date-time
example: 2018-03-20T09:12:28Z
started_at:
type: string
format: string
example: 2018-03-20T09:12:28Z JSON: "schemas": {
"TestData": {
"type": "object",
"properties": {
"created_at": {
"type": "string",
"format": "date-time"
},
"last_updated_at": {
"type": "string",
"format": "date-time",
"example": "2018-03-20T09:12:28Z"
},
"started_at": {
"type": "string",
"format": "string",
"example": "2018-03-20T09:12:28Z"
}
}
}
} However, when rendered in swagger-ui, using {
"created_at": "2022-07-14T10:23:48.664Z",
"last_updated_at": {},
"started_at": {}
} DiagnosisWhen the OpenAPI UI is loaded, it first fetches the OpenAPI document from
Therefore I think two things have gone wrong:
ConclusionIt's possible for you to work around the issue by updating to I will work on improving the parsing of the I will look into raising a bug with Swagger UI on the way they parse timestamps in examples. |
@Azquelt Thank you for quick response, your means that microprofile-openapi-2.0 fix the issue? But we have tried microprofile-openapi-2.0.1 still does not work. |
Yes, using the |
Describe the bug
![image](https://user-images.githubusercontent.com/78241853/177963114-6a56c81c-4df9-44cf-8223-07d3bba2a351.png)
![image](https://user-images.githubusercontent.com/78241853/177963300-5fb933b0-12d3-4bbc-bf44-c2bff308411f.png)
Original bug from here eclipse/microprofile-open-api#543
Based on open liberty and MicroProfile OpenAPI [2.0.1], We want to display example for date-time field as this format "YYYY-MM-DDTHH:MM:SSZ" in the web html, so we Sechema defined as bellow in Java code:
@Schema(name = "created_at", format = "date-time")
@Schema(name = "last_updated_at", format = "date-time", example = "2018-03-20T09:12:28Z")
@Schema(name = "started_at", format = "string", example = "2018-03-20T09:12:28Z")
Steps to Reproduce
After build code, and deploy local-host liberty, check http://localhost:9080/openapi/ui, Schema display OrderedMap error
And Example value will display as bellow: for the first item did not use example, it will display "YYYY-MM-DDTHH:MM:SS.MSSZ", and for others example, it will display {}
Expected behavior
![image](https://user-images.githubusercontent.com/78241853/177963910-79f69bf6-fb56-4883-ac6a-2f95ef169518.png)
Diagnostic information:
$WLP_OUTPUT_DIR/messages.log
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: