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

An OAS with circular schema definitions fails to create API proxy #199

Closed
kurtkanaskie opened this issue May 8, 2023 · 3 comments · Fixed by #200
Closed

An OAS with circular schema definitions fails to create API proxy #199

kurtkanaskie opened this issue May 8, 2023 · 3 comments · Fixed by #200

Comments

@kurtkanaskie
Copy link
Collaborator

Given the attached OAS the following command fails with or without --validate false

$ apigeecli -t $TOKEN apis create openapi -n leo-clm-basic -f circular-reference.json -o apigeex-payg-kurt --validate false
ERROR: 2023/05/08 09:20:28 generateapi.go:119: kin-openapi bug found: circular schema reference not handled - #/components/schemas/TypeInfo -> #/components/schemas/Type -> #/components/schemas/Type -> #/components/schemas/Type -> #/components/schemas/Type
Error: kin-openapi bug found: circular schema reference not handled - #/components/schemas/TypeInfo -> #/components/schemas/Type -> #/components/schemas/Type -> #/components/schemas/Type -> #/components/schemas/Type

Other tools (e.g. openapi2apigee) and the UI to create the proxy and to add an Open API Spec Validation policy, process the OAS without errors.

Rename to circular-reference.json
circular-reference-json.txt

srinandan added a commit that referenced this issue May 8, 2023
@srinandan
Copy link
Collaborator

I don't think it can be fixed within apigeecli. The error is coming from LoadFile and not schema format validation.

I did detect a problem with how format validation is enabled/disabled. I have fixed that portion.

@kurtkanaskie
Copy link
Collaborator Author

I see there was a solution on the kin-openapi repo, the fix was to create a package-wide CircularReferenceCounter variable.
I added the following to LoadDocumentFromFile and LoadDocumentFromURL in generateapi.go

openapi3.CircularReferenceCounter = 100

That fixed the issue with the OAS I shared.

@kurtkanaskie
Copy link
Collaborator Author

This fix is also needed in LoadDocumentFromURI and I think the value should be higher.

openapi3.CircularReferenceCounter = 20

For the use case I had, this URL required the circular reference counter to be 11 or greater, value of 10 caused "circular schema reference" error.

apis create openapi --import=false -n leo-clm-basic -u https://api-leoaksdev.gep.com/leo-clm-basic/swagger/v1/swagger.json

@srinandan srinandan linked a pull request May 10, 2023 that will close this issue
srinandan added a commit that referenced this issue May 10, 2023
* bug: fixes format validation #199

* bug: set circular reference counter #199

* bug: set circular reference counter #199
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.

2 participants