Skip to content

Response type does not de-reference $refs #18

Closed
@azz

Description

@azz
openapi: '3.0.0'

info:
  description: 'Description'
  version: 'latest'
  title: 'Title'

paths:
  '/api':
    get:
      operationId: getData
      responses:
        200:
          $ref: '#/components/responses/default'

components:
  responses:
    default:
      description: OK
      content:
        'application/json':
          schema:
            type: object
            properties:
              data: { type: string }

Generates the types:

export namespace api {

  /**
  * @name getData
  * @request GET:/api
  */
  export namespace GetData {
    export type RequestQuery = {};
    export type RequestBody = never;
    export type ResponseBody = any;
  }
}

However if the response type is inlined:

openapi: '3.0.0'

info:
  description: 'Description'
  version: 'latest'
  title: 'Title'

paths:
  '/api':
    get:
      operationId: getData
      responses:
        200:
          description: OK
          content:
            'application/json':
              schema:
                type: object
                properties:
                  data: { type: string }

The correct type is output:

export namespace api {

  /**
  * @name getData
  * @request GET:/api
  */
  export namespace GetData {
    export type RequestQuery = {};
    export type RequestBody = never;
    export type ResponseBody = { data?: string };
  }
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions