GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix: Allow multiple JSON types to be generated by jamietanna · Pull Request #1159 · oapi-codegen/oapi-codegen

Conversation

@jamietanna

@jamietanna jamietanna commented Jul 31, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@jamietanna
jamietanna requested a review from a user July 31, 2023 11:51
@jamietanna
jamietanna force-pushed the defect/multi-json branch from 1d8a51b to 5dbff79 Compare July 31, 2023 11:52
@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
@jamietanna
Fix: Allow multiple JSON types to be generated
90577f2
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 force-pushed the defect/multi-json branch from a9cf1ca to 90577f2 Compare July 31, 2023 13:56
@jamietanna
jamietanna marked this pull request as ready for review July 31, 2023 13:58
@jamietanna jamietanna mentioned this pull request Jul 31, 2023
Multiple json content types in a single requestBody or response lead to duplicate types and client interface functions #1127
Closed
@ghost
ghost merged commit b248b1d into master Jul 31, 2023
@jamietanna
jamietanna deleted the defect/multi-json branch July 31, 2023 20:16
This was referenced Aug 3, 2023
Generated API code no longer compiles after upgrade form 1.12.4 to 1.13.2 #1168
Closed
fix: correct marshalling for +json types for strict servers #1171
Merged
debuggerpk pushed a commit to breuHQ/oapi-codegen that referenced this pull request Sep 18, 2023
@jamietanna Yousuf Jawwad
Fix: Allow multiple JSON types to be generated (oapi-codegen#1159)
461d9bf
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
@jamietanna @danicc097
Fix: Allow multiple JSON types to be generated (oapi-codegen#1159)
2800a93
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Multiple json content types in a single requestBody or response lead to duplicate types and client interface functions

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@jamietanna
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.