Description
When additionalProperties are on the root of a schema and they point to a $ref of another schema, the generated code for the API does not include the import statement for the model. The generated code attempts to use the model, but the code fails to compile due to the missing import.
openapi-generator version
3.3.0-SNAPSHOT
OpenAPI declaration file content or url
components:
schemas:
A:
type: object
properties:
name:
type: string
additionalProperties:
$ref: '#/components/schemas/B'
B:
type: object
properties:
id:
type: string
value:
anyOf:
- type: string
- type: integer
Full test yaml: https://gist.github.com/johnkoerner/faea41ec36ddea55d6522752b9981452
Command line used for generation
openapi-generator generate -i Test.yaml -g typescript-node -o ./ts
Steps to reproduce
- Generate the typescript using the command above
- Attempt to build the typescript using
tsc ./ts/api.ts
- Notice that you will get the error
error TS2304: Cannot find name 'B'.
Related issues/PRs
See #398 as that is a similar issue. Note that you need 3.3.0 or higher as there are errors you receive from the generator in prior versions.
Description
When
additionalPropertiesare on the root of a schema and they point to a$refof another schema, the generated code for the API does not include theimportstatement for the model. The generated code attempts to use the model, but the code fails to compile due to the missing import.openapi-generator version
3.3.0-SNAPSHOT
OpenAPI declaration file content or url
Full test yaml: https://gist.github.com/johnkoerner/faea41ec36ddea55d6522752b9981452
Command line used for generation
openapi-generator generate -i Test.yaml -g typescript-node -o ./tsSteps to reproduce
tsc ./ts/api.tserror TS2304: Cannot find name 'B'.Related issues/PRs
See #398 as that is a similar issue. Note that you need 3.3.0 or higher as there are errors you receive from the generator in prior versions.