Skip to content

fix(overlay): correctly resolve references after Overlay application #1825

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

Merged

Conversation

jgraeger
Copy link
Contributor

@jgraeger jgraeger commented Nov 7, 2024

When working with overlays, oapi-codegen doesn't support external references, even though they are supported for the same file without overlays.

This PR adds a new setting resolve-refs to the OverlayOutput configuration. If enabled, configures the oapi loader such as the external references are resolved as for a normal file (against the filepath of the spec).

@jgraeger jgraeger requested a review from a team as a code owner November 7, 2024 16:23
@jamietanna
Copy link
Member

Interesting - would you mind adding an example of this to internal/test?

I've not hit this before, but would be good to see what we're missing

@jgraeger
Copy link
Contributor Author

jgraeger commented Nov 7, 2024

@jamietanna Thank you for the swift review! I agree and removed config flag and enabled it by default. I also added an example to internal/test for overlay.

Apparently the issue only occurs if the spec is in a diffent directory then the one oapi-codegen is invoked from. Therefore I put the spec.yaml into the subdirectory spec/. Running go generate after setting ResolveRefs to false reproduces the error.

@jgraeger
Copy link
Contributor Author

@jamietanna Is the example sufficient or do you need more information? :)

@jamietanna
Copy link
Member

Thanks very much for this @jgraeger - this was a good catch, and I'm classing this as a bug, not a feature 😅

I've pushed a couple of tweaks - will wait for CI then merge

Main tweaks:

  • no longer making it opt-in, and instead default behaviour
  • moving the test to a different directory - you weren't expected to know this, and this is more my personal preference, what you'd done was absolutely great - thank you!

@jamietanna jamietanna merged commit cc97261 into oapi-codegen:main Nov 28, 2024
18 checks passed
@jamietanna jamietanna changed the title feat: Allow resolving references after overlay application fix(overlay): correctly resolve references after Overlay application Nov 28, 2024
@jamietanna jamietanna added the bug Something isn't working label Nov 28, 2024
@pixelsoccupied
Copy link

Tried this fix on my side and it works well! Is there any ETA for this release @jamietanna? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy