42Crunch / vscode-openapi

VisualStudio Code OpenAPI tools
GNU Affero General Public License v3.0
334 stars 41 forks source link

Circular References show errors since some recent update last 2 weeks #279

Open frankgrupe opened 2 months ago

frankgrupe commented 2 months ago

Hey, we have a very big and oldish YAML for our commerce product SAP Commerce Cloud, you should be able to access it publicly even: https://api.sap.com/api/commerce_webservices/overview

Now we use recursions / circular schemas. Some are indeed "not ideal" and we should simplify the schema... other topic We also have desired ones like: Cart has EntryGroups which can reflect bundles of entries that should be nested, we need to keep those...

Whichever example: It worked before and now out of a sudden in last weeks it started to fail and produce errors like this in the VSCode OpenAPI plugin:

ErrorsHide Resolver error at paths./{baseSiteId}/users/{userId}/carts.get.responses.200.content.application/xml.schema.properties.carts.items.properties.entries.items.properties.product.properties.productReferences.items.properties.target.$refCould not resolve reference: Failed to fetchResolver error at paths./{baseSiteId}/users/{userId}/carts.get.responses.200.content.application/xml.schema.properties.carts.items.properties.entries.items.properties.product.properties.variantMatrix.items.properties.elements.items.$refCould not resolve reference: Failed to fetchResolver error at paths./{baseSiteId}/users/{userId}/carts.get.responses.200.content.application/xml.schema.properties.carts.items.properties.entryGroups.items.properties.entryGroups.items.$refCould not resolve reference: Failed to fetchResolver error at paths./{baseSiteId}/users/{userId}/customergroups.get.responses.200.content.application/xml.schema.properties.userGroups.items.properties.subGroups.items.$refCould not resolve reference: Failed to fetchResolver error at paths./{baseSiteId}/products/search.get.responses.200.content.application/xml.schema.properties.products.items.properties.productReferences.items.properties.target.$refCould not resolve reference: Failed to fetchResolver error at paths./{baseSiteId}/products/search.get.responses.200.content.application/xml.schema.properties.products.items.properties.variantMatrix.items.properties.elements.items.$refCould not resolve reference: Failed to fetch

I wasn't 100% sure what OpenAPI should support, so found this great arrticle which I agree with https://pb33f.io/libopenapi/circular-references/ A circular reference isn’t considered something that’s broken, unless required is set to true. When a schema is required AND it’s part of a loop - an unrecoverable infinite loop.

I created a simple recursion example from petstore to reproduce the error: recursive-petstore-example.txt

this brings the same error WHEN expanding an API, NOT on loading it

image

Please help, I believe this bug has been introduced somewhen last week or a week before.

Cheers Frank

ak1394 commented 1 month ago

Thanks for reporting the issue. This is likely caused by a recent upgrade of Swagger UI library which we use to render the preview. I'll see if maybe there is a newer version that might fix the issue. In the meantime you can switch to an older version of the plugin, if it worked for you in the past.

frankgrupe commented 1 month ago

Wow, I didn't think about that at all and its really easy: right click on: extension-Install specific version...

4.18.6 works, 4.19.0 and later fails...

I might have not updated it for 9 months?! weird that I didn't recognise it earlier