crescat-io / saloon-sdk-generator

Generate Saloon SDKs from Postman Collections and OpenAPI Specifications.
MIT License
112 stars 18 forks source link

Etsy Open API encounters an error in version 1.2 #23

Closed dangnhdev closed 7 months ago

dangnhdev commented 7 months ago

Etsy OpenAPI: https://www.etsy.com/openapi/generated/oas/3.0.0.json

Command I use:

sdkgenerator generate:sdk etsy_open_api.json \
--type=openapi --name EtsySDK --output=app/Etsy --namespace=App\\Etsy --force

Version 1.1 of the package can generate successfully, whereas version 1.2 throws an error.

In ClassLike.php line 78:
  Value 'Self' is not valid class name.                                  
dangnhdev commented 7 months ago

I've identified the issue. It's because Etsy schema has the Self object which cannot be used as a class name in PHP.

"/v3/application/users/me": {
            "get": {
                "operationId": "getMe",
                "tags": ["User"],
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Self"
                                }
                            }
                        }
                    },
"Self": {
                "type": "object",
                "description": "Represents a single user of the site",
                "properties": {
                    "user_id": {
                        "type": "integer",
                        "description": "The numeric ID of a user. This number is also a valid shop ID for the user\\'s shop.",
                        "minimum": 1
                    },
                    "shop_id": {
                        "type": "integer",
                        "description": "The unique positive non-zero numeric ID for an Etsy Shop.",
                        "minimum": 1
                    }
                }
            }

Anw, I tried to use openapi-generator and found the option --skip-validate-spec option useful as it generates all the files, which help me detect this problem.
Perhaps we should also consider enabling users to bypass schema validation?