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

Fix: Allow multiple JSON types to be generated #1159

Merged
merged 1 commit into from
Jul 31, 2023

Conversation

jamietanna
Copy link
Member

@jamietanna jamietanna commented Jul 31, 2023

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 jamietanna marked this pull request as draft July 31, 2023 12:03
@jamietanna jamietanna force-pushed the defect/multi-json branch 2 times, most recently from 6f1df5d to 911d90a Compare July 31, 2023 13:18
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 jamietanna marked this pull request as ready for review July 31, 2023 13:58
@deepmap-marcinr deepmap-marcinr merged commit b248b1d into master Jul 31, 2023
8 checks passed
@jamietanna jamietanna deleted the defect/multi-json branch July 31, 2023 20:16
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants