-
Notifications
You must be signed in to change notification settings - Fork 90
Support for openapi v3/v3.1 schema formats #1291 #1494
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
Support for openapi v3/v3.1 schema formats #1291 #1494
Conversation
✅ Deploy Preview for springwolf-ui canceled.
|
...java/io/github/springwolf/core/asyncapi/components/examples/walkers/DefaultSchemaWalker.java
Show resolved
Hide resolved
...wolf-core/src/main/java/io/github/springwolf/core/asyncapi/schemas/SwaggerSchemaService.java
Show resolved
Hide resolved
springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/schemas/SwaggerSchemaUtil.java
Outdated
Show resolved
Hide resolved
.../springwolf/core/integrationtests/application/polymorphic/PolymorphicPayloadApplication.java
Show resolved
Hide resolved
d8d540e to
ad80cfa
Compare
timonback
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sam0r040 and I reviewed the PR. We enjoyed the PR very much. The PR is surprisingly sleek and it shows that you have understood and found the best place for integrating this feature.
We added some comments, suggestions. If there are questions, let us know. Some comments probably also reflect the Springwolf code style.
FYI: We committed & pushed a couple smaller changes (i.e. avoiding breaking API change)
...wolf-core/src/main/java/io/github/springwolf/core/asyncapi/schemas/SwaggerSchemaService.java
Outdated
Show resolved
Hide resolved
...re/src/main/java/io/github/springwolf/core/asyncapi/components/DefaultComponentsService.java
Outdated
Show resolved
Hide resolved
springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/schemas/SwaggerSchemaUtil.java
Outdated
Show resolved
Hide resolved
...-core/src/test/java/io/github/springwolf/core/asyncapi/schemas/SwaggerSchemaServiceTest.java
Outdated
Show resolved
Hide resolved
...ingwolf/core/integrationtests/AsyncApiDocumentWithOpenApiV31SchemaFormatIntegrationTest.java
Show resolved
Hide resolved
...est/java/io/github/springwolf/examples/jms/ApiWithOpenApiV31SchemaFormatIntegrationTest.java
Outdated
Show resolved
Hide resolved
springwolf-core/src/main/java/io/github/springwolf/core/asyncapi/schemas/SwaggerSchemaUtil.java
Outdated
Show resolved
Hide resolved
...wolf-core/src/main/java/io/github/springwolf/core/asyncapi/schemas/SwaggerSchemaService.java
Show resolved
Hide resolved
...re/src/main/java/io/github/springwolf/core/configuration/properties/PayloadSchemaFormat.java
Show resolved
Hide resolved
...est/java/io/github/springwolf/examples/jms/ApiWithOpenApiV31SchemaFormatIntegrationTest.java
Outdated
Show resolved
Hide resolved
23e6862 to
98a085c
Compare
…chema, change back public api method from registerSimpleSchema to registerSchema to prevent breaking change, rename SwaggerSchemaService.postProcessSimpleSchema to postProcessSchemaWithoutRef to clarify the intention of the method Co-authored-by: Timon Back <[email protected]>
98a085c to
f3b6093
Compare
…on of ModelConvertersProvider from 'afterPropertiesSet' to the constructor.
…t only for the asyncapi artifact
Kafka example includes many more listener, schemas and possible edge cases
timonback
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started looking at the output openapiv3 file it is looks quite similar. Besides that the json-schema extension is not really supported, the rest looks fine or related to the difference between openapi 3.0 vs 3.1
Testing:
-> remove runtimeOnly project(":springwolf-add-ons:springwolf-json-schema")
-> add @JsonPropertyOrder(alphabetic = true) to SchemaObject for easier comparison
One more question, when using the payloadSchemaFormat, why not also format the header schemas using the same setting?
Does your use-case only require the payloads in one format and the headers in the default?
I would have assumed that if I change it, all schema change.
|
Yes, Asyncapi and OpenAPI schema formats are quite similar. The main difference lies in the area of inheritance. Schema classes with defined discriminator fields and values are not (well) implemented by Asyncapi. That was the original motivation for this pull request. The main reason for not using the payload schema format for the headers was that the headers are usually so simple that there are no differences between AsyncAPI and OpenAPI. I thought it would unnecessarily bloat the resulting AsyncAPI by turning every headers block into a MultiSchemaFormat header: to But I must admit that the overhead is not that large at all. So - It might simplify the implementation if the schemaformat is used globally for payload and headers. I would try change the PR towards a global asyncapi schemaformat. What do you think is a good propertyname / Enum classname instead of 'PayloadSchemaFormat'? Simply 'SchemaFormat' (which already exists), 'AsyncApiSchemaFormt' oder 'OutputSchemaFormat' ? |
|
Sounds good. Since it is the configuration for schemaFormat, it can also be called SchemaFormat. If that is confusing with the asyncapi one, maybe SchemaFormatConfig? I am mostly concerned about complexity and maintainability in the long term. We are a small team, so the easier it is now (also to contribute) the more features and less bugs are shipped. A bloated document can be improved later as an optimisation, possibly also via a serialiser. (Actually, I was considering if it is easier, when internally everything is a MultiFormatSchema and therefore less checking if this else that) |
…t directly from global configuration Co-authored-by: Timon Back <[email protected]>
Co-authored-by: sam0r040 <[email protected]>
I introduced a new Property
springwolf.docket.payload-schema-formatwhich is an enum and supports currentlyWith the default-setting (asyncapi_v3), SpringWolf behaves as before.
Enabling openapi_v3 or _v3_1 leads to a AsyncApi where the payload schemas (not the header schemas!) are formatted with openapi v3/v3.1 format. This is possible and allowed because the AsyncApi Spec supports the definition of alternative schema formats.
The openapi v3/v3.1 schema formats are especially helpful when it comes to polymorphic schemas with custom discrimiantor mappings (which are not possible to describe with default asyncapi schema format).