feat: [OpenAPI] Type and Import mapping support #1010
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.
Context
When OpenAPI generator find the following schema in input spec file, particularly the mention
string+binary, it maps the response to typeFile.Unfortunately, while invoking any API method that returns
Filetype, we will run into the following error. (Find the bug report in linked BLI)The issue above suggests that the mapped type
Fileis simply unsupported and should be changed. We have had similar issues in the past which could have simply been resolved with a different type mapping. So instead of a per-type fix, we can resort to a more generic solution. To do so, we can take advantage of the<typeMappings>and<importMappings>features of OpenAPI generator. They are can be set via the OpenAPI generator CLI or through thepom.xml.<typeMappings>: allow you to override OpenAPI type with some custom type<importMappings>: allows you to replace the file imports for any type with another qualified path. Often used in tandem with defined<typeMappings>to correct the import statements.Problem:
Our OpenAPI generator wrapper and corresponding maven plugin, does not accept
<typeMappings>and<importMappings>. The goal of this PR is to propagate their configuration down to the OpenAPI generator.Feature scope:
<typeMappings><importMappings>openapi-api-sampleto demo fix for related bug reportDefinition of Done
Error handling created / updated & covered by the tests aboveDocumentation updated