-
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
Open
tvahrst
wants to merge
16
commits into
springwolf:master
Choose a base branch
from
tvahrst:componentschema-refactoring
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
a92b4e5
feat: schemaformat option for payload schemas added
tvahrst 491cbd6
feat: tests for schemaformat option for payload schemas added
tvahrst 0e45567
chore: spotless
tvahrst 3122687
chore: javadoc
tvahrst 109f50e
chore: spotless
tvahrst 3c2e3dc
fix: tests
tvahrst ad80cfa
fix: tests
tvahrst f3b6093
chore(core): move wrapper logic for MultiFormatSchema to MultiFormatS…
sam0r040 1ca9a79
Merge branch 'springwolf:master' into componentschema-refactoring
tvahrst ca1b83d
chore: ModelConvertersProvider and some minor enhancements.
tvahrst f9e1ac5
chore: spotless
tvahrst 4560d69
update tests for new ModelConvertersProvider bean. Moved initializati…
tvahrst a6f63e0
feat(core): use PayloadSchemaFormat internally, switch to SchemaForma…
timonback 94c7134
Merge branch 'master' into componentschema-refactoring
timonback aba7bf7
chore: move OpenAPIv3 integration test to kafka example
timonback 014bcb9
spotless
tvahrst File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...ore/src/main/java/io/github/springwolf/core/asyncapi/schemas/ModelConvertersProvider.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| package io.github.springwolf.core.asyncapi.schemas; | ||
|
|
||
| import io.github.springwolf.asyncapi.v3.model.schema.SchemaFormat; | ||
| import io.github.springwolf.core.configuration.properties.PayloadSchemaFormat; | ||
| import io.swagger.v3.core.converter.ModelConverter; | ||
| import io.swagger.v3.core.converter.ModelConverters; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| /** | ||
| * Provides fully prepared {@link io.swagger.v3.core.converter.ModelConverters} for openapi v3 and v3.1 | ||
| * requirements. | ||
| */ | ||
| public class ModelConvertersProvider { | ||
|
|
||
| private final ModelConverters converter_openapi30; | ||
| private final ModelConverters converter_openapi31; | ||
|
|
||
| public ModelConvertersProvider(List<ModelConverter> externalModelConverters) { | ||
| converter_openapi30 = new ModelConverters(false); | ||
| converter_openapi31 = new ModelConverters(true); | ||
| externalModelConverters.forEach(converter_openapi30::addConverter); | ||
| externalModelConverters.forEach(converter_openapi31::addConverter); | ||
| } | ||
|
|
||
| /** | ||
| * provides the appropriate {@link ModelConverters} for the given {@link SchemaFormat}. | ||
| * | ||
| * @param schemaFormat the schemaFormat that shall be generated. | ||
| * @return the appropriate {@link ModelConverters} or {@link IllegalArgumentException} if the given format is not supported. | ||
| */ | ||
| public ModelConverters getModelConverterFor(PayloadSchemaFormat schemaFormat) { | ||
| return switch (schemaFormat) { | ||
| case ASYNCAPI_V3, OPENAPI_V3 -> converter_openapi30; | ||
| case OPENAPI_V3_1 -> converter_openapi31; | ||
| }; | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
building examples from types happend to be a little bit 'tricky' because openapi v3 and v3.1 changed the field for the type(s). I moved the "type-lookup" in an extra method 'getTypeForExampleValue'.