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

Loading error: kin-openapi bug found: circular schema reference not handled #814

Closed
17twenty opened this issue Jun 23, 2023 · 4 comments · Fixed by #815
Closed

Loading error: kin-openapi bug found: circular schema reference not handled #814

17twenty opened this issue Jun 23, 2023 · 4 comments · Fixed by #815

Comments

@17twenty
Copy link

17twenty commented Jun 23, 2023

Using with oapi-codegen I had errors trying to build out the Client from the code using:

#!/usr/bin/env
  FILE=xero_accounting.yaml

  ORIGINAL_STRIPPED=$(basename $FILE .yaml);
  NEW=$(echo $ORIGINAL_STRIPPED | tr 'xero-' 'xero_' | sed 's/xero_//')
  # Generate the API spec
  echo Generating from "$ORIGINAL_STRIPPED"
  mkdir -p "$PACKAGE_NAME/$NEW/"
  oapi-codegen --package=main -generate=types,client  -package "$PACKAGE_NAME" "$FILE" > "$PACKAGE_NAME/$NEW".gen.go

The output from that command being:

bash ./generator/scripts/golang/gen.sh
Generating from xero_accounting
error loading swagger spec in xero_accounting.yaml
: kin-openapi bug found: circular schema reference not handled - #/components/schemas/ExpenseClaim -> #/components/schemas/Payment -> #/components/schemas/CreditNote -> #/components/schemas/Payment -> #/components/schemas/Prepayment -> #/components/schemas/Allocation -> #/components/schemas/Prepayment -> #/components/schemas/Payment -> #/components/schemas/Invoice -> #/components/schemas/Payment

I followed up to use the latest kin-openapi as referenced in #764 but still see the below issue:

go run github.com/getkin/kin-openapi/cmd/validate@latest -- xero_accounting.yaml 
go: downloading github.com/getkin/kin-openapi v0.118.0
go: downloading github.com/perimeterx/marshmallow v1.1.4
2023/06/23 11:10:58 Loading error: kin-openapi bug found: circular schema reference not handled - #/components/schemas/Overpayment -> #/components/schemas/Payment -> #/components/schemas/Overpayment -> #/components/schemas/Allocation -> #/components/schemas/Invoice -> #/components/schemas/Prepayment -> #/components/schemas/Payment -> #/components/schemas/BatchPayment -> #/components/schemas/Payment -> #/components/schemas/CreditNote -> #/components/schemas/Allocation -> #/components/schemas/Invoice -> #/components/schemas/CreditNote -> #/components/schemas/Payment
exit status 1
@fenollp
Copy link
Collaborator

fenollp commented Jun 23, 2023

Hi @17twenty could you share you openapi document?
If you can't post it here as a minimized example, you should find my email address on my profile.

@17twenty
Copy link
Author

No worries Pierre - I'm using the xero_accounting.yaml from their OpenAPI repo they use as their source for SDKs - https://raw.githubusercontent.com/XeroAPI/Xero-OpenAPI/master/xero_accounting.yaml

I've opened up a ticket on their repo as well to see if they can assist with their approach as I also tried flattening the spec and couldn't get joy with that - XeroAPI/Xero-OpenAPI#563

@fenollp
Copy link
Collaborator

fenollp commented Jun 23, 2023

Erm not sure this should be closed but => #815
Note that the circular ref issue is known and #695 should lay the groundwork towards fixing it.

Feel free to reopen if you'd like. To me one should make a PR at https://github.com/deepmap/oapi-codegen to allow passing --circular=INT as I did in the above PR.

@jamietanna
Copy link
Contributor

Thanks for the work on this @fenollp 👏

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 a pull request may close this issue.

3 participants