umbraco / Umbraco.Commerce.Issues

17 stars 2 forks source link

Storefront Swagger JSON is invalid #558

Open tkf-ordeno opened 1 month ago

tkf-ordeno commented 1 month ago

Describe the bug I was generating TypeScript models with the Storefront Swagger JSON and got this error:

ERROR ✘ Every operation must have a unique operationId.

And looking at the Swagger docs this is also documented at https://swagger.io/docs/specification/paths-and-operations/

operationId is an optional unique string used to identify an operation. If provided, these IDs must be unique among all operations described in your API.

When inspecting the Storefront swagger.json it seems the operationIds that has duplicates is

Umbraco Commerce version: Umbraco.Commerce 14.0

tkf-ordeno commented 1 month ago

On a related note - I manually edited the operationIds in the JSON, but when I generated the TypeScript models again with https://github.com/openapi-ts/openapi-typescript/tree/main/packages/openapi-typescript

Then the following Storefront Swagger JSON snippet: image

For the endpoint /umbraco/commerce/storefront/api/v1/store/{idOrAlias}

Will generate the following TypeScript: image

Which will make values like Billing-Country impossible to assign a value in TypeScript. Maybe avoid oneOf for simple string values?

mattbrailsford commented 3 weeks ago

Thanks for reporting this. We have learned a lot since creating the Storefront API where this wasn't originally taken into account. Given this would be considered a breaking change however, we will only be able to address this in v15. I believe this should already be resolved in the v15 codebase, but I'll leave this open until we make a release.