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

New configuration property mp.openapi.extensions.smallrye.merge-schema-examples = false does not always work #2131

Open
dhoffer opened this issue Jan 6, 2025 · 4 comments

Comments

@dhoffer
Copy link

dhoffer commented Jan 6, 2025

If I set mp.openapi.extensions.smallrye.merge-schema-examples = false I get some strange results.

With this as my Pojo

@JsonView(Views.Abridged.class)
@Schema(description = "An array of date-time in ISO8601 UTC format with millisecond precision.", example = "[\"2021-10-25T16:00:00.234Z\", \"2021-10-26T16:00:00.234Z\"]")
private List<LocalDateTime> rcvyTime;

I get this generated OpenAPI.

"rcvyTime": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "date-time",
              "examples": [
                "2022-03-10T12:15:50"
              ]
            },
            "description": "An array of date-time in ISO8601 UTC format with millisecond precision.",
            "example": [
              "2021-10-25T16:00:00.234Z",
              "2021-10-26T16:00:00.234Z"
            ]
          }

Where did this come from? It should not exist.

 "examples": [
                "2022-03-10T12:15:50"
              ]

And that appears to be a default value as all arrays that do this have the same value.

Note I am using 4.0.6-SNAPSHOT

@MikeEdgar
Copy link
Member

That's the default example for date-time strings:

private static final TypeWithFormat LOCAL_DATE_TIME_FORMAT = TypeWithFormat.of(SchemaType.STRING)
.format(DataFormat.DATE_TIME)
.example("2022-03-10T12:15:50").build();

You should be able to suppress it by overriding the schema for LocalDateTime:

mp.openapi.schema.java.time.LocalDateTime={ "type": "string", "format": "date-time" }

@dhoffer
Copy link
Author

dhoffer commented Jan 7, 2025

So, in yaml would that be this? It did not work.

mp: openapi: schema: java: time: LocalDateTime: type: "string" format: "date-time"

@MikeEdgar
Copy link
Member

Try this. The value should be a string.

mp:
  openapi:
    schema:
      java:
        time:
          LocalDateTime: '{ "type": "string", "format": "date-time" }'

@dhoffer
Copy link
Author

dhoffer commented Jan 7, 2025

Yes that does work, thank you.

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

No branches or pull requests

2 participants