Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[typescript-node] Add RequestFile to typescript-node model template #4903

Merged
merged 1 commit into from Jan 6, 2020
Merged

[typescript-node] Add RequestFile to typescript-node model template #4903

merged 1 commit into from Jan 6, 2020

Commits on Jan 1, 2020

  1. Add RequestFile to typescript-node model template

    RequestFile is defined in the [api-all.mustache
    template](https://github.com/OpenAPITools/openapi-generator/blob/ac4ead9e7805d4dc89d791376539496a57c49df7/modules/openapi-generator/src/main/resources/typescript-node/api-all.mustache#L29),
    and it gets used [as a special
    case](https://github.com/OpenAPITools/openapi-generator/blob/ac4ead9e7805d4dc89d791376539496a57c49df7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNodeClientCodegen.java#L92)
    [in the model.mustache
    template](https://github.com/OpenAPITools/openapi-generator/blob/ac4ead9e7805d4dc89d791376539496a57c49df7/modules/openapi-generator/src/main/resources/typescript-node/model.mustache#L21).
    
    When this special case is triggered and `RequestFile` is used in a model
    file, Typescript complains that the type is not found.
    
    ```
    TSError: Unable to compile TypeScript:
    path/to/model.ts:15:16 - error TS2304: Cannot find name 'RequestFile'.
    
    15      'myFile'?: RequestFile;
                       ~~~~~~~~~~~
    ```
    
    This solution is to import `RequestFile` by adding it to the model
    template.
    
    Here is an openapi schema that would trigger this use-case:
    
    ```yaml
    openapi: 3.0.0
    components:
        schemas:
            IUploadMyFileBody:
                type: object
                properties:
                    myFile:
                        type: string
                        format: binary
    ```
    ryannjohnson committed Jan 1, 2020
    Copy the full SHA
    de9fe26 View commit details
    Browse the repository at this point in the history