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

[BUG] openapi-generator 7.2.0 is no longer able to resolve local $refs #17554

Closed
4 of 6 tasks
ctreatma opened this issue Jan 8, 2024 · 4 comments
Closed
4 of 6 tasks

Comments

@ctreatma
Copy link
Contributor

ctreatma commented Jan 8, 2024

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

We are attempting to upgrade our SDK generation process from openapi-generator 7.1.0 to 7.2.0, but 7.2.0 fails to find most of our OpenAPI spec; the output is littered with errors like this:

-Unable to load RELATIVE ref: ../../../components/schemas/CapacityList.yaml

The only change we're making is the openapi-generator version, so the files still exist in the same location; 7.1.0 is able to find them but 7.2.0 isn't. After some poking it appears the issue is caused by the upgrade from swagger-parser 2.1.18 to 2.1.19.

openapi-generator version
OpenAPI declaration file content or url
Generation Details

I haven't had a chance to create a smaller reproduction case, but our upgrade attempt is here: equinix/equinix-sdk-go#15

Steps to reproduce

Check out the PR linked above and run make -f Makefile.metalv1 generate.

Related issues/PRs
Suggest a fix

I haven't identified the specific change in swagger-parser 2.1.19 that caused this bug, so there is currently no way to fix the bug by upgrading. In the meantime, downgrading swagger-parser to 2.1.18 would fix this bug.

@displague
Copy link

displague commented Jan 9, 2024

There is work in progress (swagger-api/swagger-parser#2030) that is based on the PR that I suspect introduced the changed (swagger-api/swagger-parser#1994):

If 1994 included local file reference tests this regression may have been caught. Perhaps 2030 could add such a test.

@vbauer
Copy link
Contributor

vbauer commented Jan 12, 2024

It look like we have the same problem with version 7.2.0. Schemes located in the same file thats describing the operation are no longer visible to the parser:

[main] WARN  o.o.codegen.utils.ModelUtils - #/GetChatsResponse is not defined
[main] WARN  o.o.codegen.utils.ModelUtils - Failed to get the schema name: #/GetChatsResponse
[main] WARN  o.o.codegen.utils.ModelUtils - #/GetChatsResponse is not defined
[main] WARN  o.o.codegen.utils.ModelUtils - Failed to get the schema name: #/GetChatsResponse
[main] WARN  o.o.codegen.DefaultCodegen - Error obtaining the datatype from ref: #/GetChatsResponse. Default to 'object'
[main] WARN  o.o.codegen.utils.ModelUtils - Failed to get the schema name: #/GetChatsResponse
[main] WARN  o.o.codegen.utils.ModelUtils - Failed to get the schema name: #/GetChatsResponse
[main] WARN  o.o.codegen.utils.ModelUtils - Failed to get the schema name: #/GetChatsResponse
[main] WARN  o.o.codegen.utils.ModelUtils - Failed to get the schema name: #/GetChatsResponse
[main] WARN  o.o.codegen.utils.ModelUtils - #/GetChatsResponse is not defined
[main] WARN  o.o.codegen.utils.ModelUtils - Failed to get the schema name: #/GetChatsResponse

Our specification: https://github.com/yandex-market/yandex-market-partner-api

Everything was fine in version 7.1.0

@ttrubinov
Copy link

I've created an issue in swagger-parser repo about this bug
swagger-api/swagger-parser#2037

@ctreatma
Copy link
Contributor Author

This was fixed in 7.3.0 by reverting the swagger-parser upgrade. A Go test was added to attempt to catch similar issues caused by parser upgrades in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants