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

Process nested schema references #50

Closed
wants to merge 2 commits into from

Conversation

McSym28
Copy link
Contributor

@McSym28 McSym28 commented Jun 5, 2024

I was trying to generate a library using one of our local bank's Open APIs (unfortunately it's only available in Ukrainian). I've extracted the JSON spec from page's source and passed it to your great library. Unfortunately I was getting an error when processing a "nested schema reference". The error looks something like this:

** (KeyError) key {"{REDACTED}/open-api-generator/test/fixture/schema-reference.yaml", ["components", "schemas", "{REDACTED}"]} not found in: {REDACTED}
    :erlang.map_get({"{REDACTED}/test/fixture/schema-reference.yaml", ["components", "schemas", "{REDACTED}"]}, {REDACTED}
    (oapi_generator 0.1.1) lib/open_api/processor/type.ex:93: OpenAPI.Processor.Type.from_schema/2
    (oapi_generator 0.1.1) lib/open_api/processor.ex:367: anonymous fn/5 in OpenAPI.Processor.process_response_body/4
    {REDACTED}

I've added a slim spec to simulate an error. Not sure what is the best approach to tackle this or if you want to support this case in your library. I've had another attempt in a different branch, but this one looks cleaner, IMO.

P.S. Thanks for your great work!

@McSym28
Copy link
Contributor Author

McSym28 commented Jun 6, 2024

I've ran the generate job on a open-api-diffs fork and the tag was created successfully - oapi_generator/527cac2. Have I missed some config/setting?

@aj-foster
Copy link
Owner

Hi @McSym28, thanks for reporting this. I took a slightly different route to resolving this issue in #56. If you have time, coudl you check it out and see if it works for you?

Thanks! ❤️

aj-foster added a commit that referenced this pull request Jul 8, 2024
aj-foster added a commit that referenced this pull request Jul 8, 2024
@aj-foster aj-foster closed this in #56 Jul 8, 2024
@McSym28
Copy link
Contributor Author

McSym28 commented Jul 9, 2024

Hi @aj-foster. This works for me. I've made a similar change in my first attempt. The only difference is that my solution is limited to only #/components/schemas/* references.
Thanks!

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

Successfully merging this pull request may close these issues.

2 participants