Fix: Allow multiple JSON types to be generated#1159
Merged
1 commit merged intoJul 31, 2023
Merged
Conversation
jamietanna
force-pushed
the
defect/multi-json
branch
from
July 31, 2023 11:52
1d8a51b to
5dbff79
Compare
jamietanna
marked this pull request as draft
July 31, 2023 12:03
jamietanna
force-pushed
the
defect/multi-json
branch
2 times, most recently
from
July 31, 2023 13:18
6f1df5d to
911d90a
Compare
As flagged in #1127, the use of `IsMediaTypeJson` leads to potentially having duplicate types generated, leading to compilation errors. We can instead only generate i.e. `CreateWhateverJSONRequestBody` for the `application/json` type, and then construct a specific type for each media type with a matching name. This requires we add a new utility method `IsJSON` to simplify our checks, and wire it in in each place that requires we render JSON-specific code. Closes #1127.
jamietanna
force-pushed
the
defect/multi-json
branch
from
July 31, 2023 13:56
a9cf1ca to
90577f2
Compare
jamietanna
marked this pull request as ready for review
July 31, 2023 13:58
This was referenced Aug 3, 2023
debuggerpk
pushed a commit
to breuHQ/oapi-codegen
that referenced
this pull request
Sep 18, 2023
As flagged in oapi-codegen#1127, the use of `IsMediaTypeJson` leads to potentially having duplicate types generated, leading to compilation errors. We can instead only generate i.e. `CreateWhateverJSONRequestBody` for the `application/json` type, and then construct a specific type for each media type with a matching name. This requires we add a new utility method `IsJSON` to simplify our checks, and wire it in in each place that requires we render JSON-specific code. Closes oapi-codegen#1127.
danicc097
pushed a commit
to danicc097/oapi-codegen
that referenced
this pull request
Aug 31, 2024
As flagged in oapi-codegen#1127, the use of `IsMediaTypeJson` leads to potentially having duplicate types generated, leading to compilation errors. We can instead only generate i.e. `CreateWhateverJSONRequestBody` for the `application/json` type, and then construct a specific type for each media type with a matching name. This requires we add a new utility method `IsJSON` to simplify our checks, and wire it in in each place that requires we render JSON-specific code. Closes oapi-codegen#1127.
This pull request was closed.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
As flagged in #1127, the use of
IsMediaTypeJsonleads to potentiallyhaving duplicate types generated, leading to compilation errors.
We can instead only generate i.e.
CreateWhateverJSONRequestBodyforthe
application/jsontype, and then construct a specific type for eachmedia type with a matching name.
This requires we add a new utility method
IsJSONto simplify ourchecks, and wire it in in each place that requires we render
JSON-specific code.
Closes #1127.