forked from loafle/openapi-generator-original
Add RequestFile to typescript-node model template (#4903)
RequestFile is defined in the [api-all.mustache template](ac4ead9e78/modules/openapi-generator/src/main/resources/typescript-node/api-all.mustache (L29)
), and it gets used [as a special case](ac4ead9e78/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNodeClientCodegen.java (L92)
) [in the model.mustache template](ac4ead9e78/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 ```
This commit is contained in:
parent
ec1e9a4c9b
commit
d51354783f
@ -1,6 +1,7 @@
|
||||
{{>licenseInfo}}
|
||||
{{#models}}
|
||||
{{#model}}
|
||||
import { RequestFile } from '../api';
|
||||
{{#tsImports}}
|
||||
import { {{classname}} } from '{{filename}}';
|
||||
{{/tsImports}}
|
||||
|
@ -10,6 +10,7 @@
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
import { RequestFile } from '../api';
|
||||
|
||||
/**
|
||||
* Describes the result of uploading an image resource
|
||||
|
@ -10,6 +10,7 @@
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
import { RequestFile } from '../api';
|
||||
|
||||
/**
|
||||
* A category for a pet
|
||||
|
@ -10,6 +10,7 @@
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
import { RequestFile } from '../api';
|
||||
|
||||
/**
|
||||
* An order for a pets from the pet store
|
||||
|
@ -10,6 +10,7 @@
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
import { RequestFile } from '../api';
|
||||
import { Category } from './category';
|
||||
import { Tag } from './tag';
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
import { RequestFile } from '../api';
|
||||
|
||||
/**
|
||||
* A tag for a pet
|
||||
|
@ -10,6 +10,7 @@
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
import { RequestFile } from '../api';
|
||||
|
||||
/**
|
||||
* A User who is purchasing from the pet store
|
||||
|
@ -10,6 +10,7 @@
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
import { RequestFile } from '../api';
|
||||
|
||||
/**
|
||||
* Describes the result of uploading an image resource
|
||||
|
@ -10,6 +10,7 @@
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
import { RequestFile } from '../api';
|
||||
|
||||
/**
|
||||
* A category for a pet
|
||||
|
@ -10,6 +10,7 @@
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
import { RequestFile } from '../api';
|
||||
|
||||
/**
|
||||
* An order for a pets from the pet store
|
||||
|
@ -10,6 +10,7 @@
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
import { RequestFile } from '../api';
|
||||
import { Category } from './category';
|
||||
import { Tag } from './tag';
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
import { RequestFile } from '../api';
|
||||
|
||||
/**
|
||||
* A tag for a pet
|
||||
|
@ -10,6 +10,7 @@
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
import { RequestFile } from '../api';
|
||||
|
||||
/**
|
||||
* A User who is purchasing from the pet store
|
||||
|
Loading…
x
Reference in New Issue
Block a user