openapistack / openapicmd

The CLI for all things OpenAPI and Swagger
https://openapistack.co
MIT License
55 stars 9 forks source link

Default response isn't set as the OperationResponse type #59

Closed kiikka closed 2 months ago

kiikka commented 2 months ago

Hello!

I'm generating a type file for the client and I noticed that a response type "default" isn't set as the OperationResponse type in the generated file. It is always set as "any". In my case default is the only one I have defined in the yaml.

Yaml

/things:
    get:
      tags:
        - Things
      description: Get Things
      operationId: getThings
      responses:
        default:
          description: default response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Things"
            application/xml:
              schema:
                $ref: "#/components/schemas/Things"`

openapi.d.ts

namespace GetThings {
        namespace Responses {
            export type Default = Components.Schemas.Things;
        }
    }
'getThings'(
    parameters?: Parameters<UnknownParamsObject> | null,
    data?: any,
    config?: AxiosRequestConfig
  ): OperationResponse<any>

Is this intentional behaviour that default responses aren't set as the OperationResponse's type.

anttiviljami commented 2 months ago

Nice catch, Aleksi! 👍

Fix available in openapicmd@2.6.1

kiikka commented 2 months ago

Thanks for the quick fix!