Generate Typescript union from OpenAPI 3.0.0 spec using openapi-generator?

Viewed 35

Currently using 3.0.3 of the OpenAPI spec, because that's that latest that version 6.0.0 of openapi-generator supports at this time.

We generate typescript for the app browser client and java for the server.

Current OpenAPI spec, that generates a status field of type string:

    UpdateAuthzResponse:
      description: > 
        'APPROVED' or 'REQUESTED'
      type: object
      required: [status]
      properties:
        status: {type: string}

For typescript this currently generates something like:

export interface UpdateAuthzResponse {
    status: string;
}

Is there an OpenAPI 3.0.0 spec that would generate a Typescript union using the openapi-generator? Something like:

export interface UpdateAuthzResponse {
    status: 'APPROVED' | 'REQUESTED';
}

I guess it would just generate an enum on java side.

I'm not looking to change the tool we use on the typescript side at the moment. We may do that later, but this question is specifically about openapi-generator.

0 Answers
Related