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

OpenAPI support to register schema for a type from 3rd party lib #36646

Closed
lost22git opened this issue Oct 23, 2023 · 2 comments · Fixed by #36514
Closed

OpenAPI support to register schema for a type from 3rd party lib #36646

lost22git opened this issue Oct 23, 2023 · 2 comments · Fixed by #36514
Milestone

Comments

@lost22git
Copy link

Description

Range class is from 3rd party lib and we can not add openapi schema definition for it.

So we need to add the same definition for every field using Range type.

@Schema(title = "timeRange", implementation = String.class, example = "[2020-02-02T00:00:00Z,2022-02-02T00:00:00Z]")
Range<ZonedDateTime> timeRange

To avoid repeating myself, I would like to know if quarkus openapi provides the functionality to register schema for types of 3rd party libraries?

Implementation ideas

something like:

openapiConfig.registerSchema(
  Schema.of(new GenericType<Range<ZonedDateTime>>() {})
  .implementation(String.class).example("[,]")
  .build()
)
@quarkus-bot
Copy link

quarkus-bot bot commented Oct 23, 2023

/cc @EricWittmann (openapi), @MikeEdgar (openapi), @phillip-kruger (openapi)

@lost22git lost22git changed the title OpenAPI support register schema for a type from 3rd party lib OpenAPI support to register schema for a type from 3rd party lib Oct 23, 2023
@MikeEdgar
Copy link
Contributor

Support for this will be available when smallrye-open-api v3.7.0 is released soon, specifically from smallrye/smallrye-open-api#1609.

You would use configuration rather than an API/builder. Escapes and new-lines added for readability.

mp.openapi.schema.com.example.Range<java.time.ZonedDateTime>={ \
  "name": "ZonedDateTimeRange", \
  "type": "string", \
  "title": "timeRange", \
  "example": "[2020-02-02T00:00:00Z,2022-02-02T00:00:00Z]" \
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants