orval-labs / orval

orval is able to generate client with appropriate type-signatures (TypeScript) from any valid OpenAPI v3 or Swagger v2 specification, either in yaml or json formats. 🍺
https://orval.dev
MIT License
2.8k stars 312 forks source link

Dashes cause syntax errors #883

Open Maxim-Mazurok opened 1 year ago

Maxim-Mazurok commented 1 year ago

What are the steps to reproduce this issue?

Have this in swagger schema:

{
    "/api/v1/user/{urlType}-url": {
        "get": {
            "tags": ["V1User"],
            "parameters": [
                {
                    "name": "urlType",
                    "in": "path",
                    "required": true,
                    "schema": {
                        "type": "string"
                    }
                }
            ],
            "responses": {
                "200": {
                    "description": "Success"
                }
            }
        }
    }
}

What happens?

["api", "v1", "user", urlType - url] as const is being generated which is invalid

What were you expecting to happen?

["api", "v1", "user", urlType, "-url"] as const probably (because urlType can be ref in Vue (MaybeRef) and doing {urlType}-url will probably result in lost reactivity)

Any other comments?

This is kind of a regression of https://github.com/anymaniax/orval/issues/65 Likely introduced by the last changes that enable Vue Reactivity

Creating PR isn't a priority for me right now, we're not using that API for now, so I just did this:

export default defineConfig({
  api: {
    input: {
      override: {
        transformer: (openapi) => {
          delete openapi.paths["/api/v1/user/{urlType}-url"];
          return openapi;
        },
      },
    },
  },
});

What versions are you using?

Operating System: Ubuntu WSL Package Version: 6.15.0 Browser Version: N/A

Maxim-Mazurok commented 9 months ago

@melloware I don't have a patch for this and this isn't a priority for me, so I'll unassign myself for now so that others can claim it. If it's confirmed to be introduced by my changes - I'm happy to own the mistake and fix it.