We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Same as #6192, but affecting the new typescript generator from #6341 instead of typescript-fetch. Updated description, error messages and repro below.
When an item of an array of a map is specified through a referenced schema, the model type for the item is not imported into DefaultApi.ts.
DefaultApi.ts
For example, for an endpoint specification of:
"/characters": get: responses: "200": content: application/json: schema: additionalProperties: type: array items: $ref: "#/components/schemas/Character"
And a schema specification of:
Character: required: ["first", "name"] properties: id: type: integer name: type: string
Compiling results in the following error:
Failed to compile. /tmp/test-openapigen/src/api/apis/DefaultApi.ts TypeScript error in /tmp/test-openapigen/src/api/apis/DefaultApi.ts(54,92): Cannot find name 'Character'. TS2304 52 | * @throws ApiException if the response code was not in [200, 299] 53 | */ > 54 | public async charactersGet(response: ResponseContext): Promise<{ [key: string]: Array<Character>; } > { | ^ 55 | const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]); 56 | if (isCodeInRange("200", response.httpStatusCode)) { 57 | const body: { [key: string]: Array<Character>; } = ObjectSerializer.deserialize(
5.0.0-SNAPSHOT
https://github.com/bard/openapi-generator-missing-type-2/blob/master/example.yaml
OPENAPI_GENERATOR_VERSION=5.0.0-SNAPSHOT /tmp/openapi-generator-cli.sh generate -g typescript -i example.yaml -o ./src/api
yarn && yarn start
#5995 seems to solve a similar issue
Import the missing type into DefaultApi.ts:
// TODO: better import syntax? import { BaseAPIRequestFactory, RequiredError } from './baseapi'; import {Configuration} from '../configuration'; import { RequestContext, HttpMethod, ResponseContext, HttpFile} from '../http/http'; import {ObjectSerializer} from '../models/ObjectSerializer'; import {ApiException} from './exception'; import {isCodeInRange} from '../util'; + import {Character} from '../models/Character' /** * no description */ export class DefaultApiRequestFactory extends BaseAPIRequestFactory {
The text was updated successfully, but these errors were encountered:
👍 Thanks for opening this issue! 🏷 I have applied any labels matching special text in your issue.
The team will review the labels and make any necessary changes.
Sorry, something went wrong.
No branches or pull requests
Same as #6192, but affecting the new typescript generator from #6341 instead of typescript-fetch. Updated description, error messages and repro below.
Bug Report Checklist
Description
When an item of an array of a map is specified through a referenced schema, the model type for the item is not imported into
DefaultApi.ts
.For example, for an endpoint specification of:
And a schema specification of:
Compiling results in the following error:
openapi-generator version
5.0.0-SNAPSHOT
OpenAPI declaration file content or url
https://github.com/bard/openapi-generator-missing-type-2/blob/master/example.yaml
Command line used for generation
Steps to reproduce
OPENAPI_GENERATOR_VERSION=5.0.0-SNAPSHOT /tmp/openapi-generator-cli.sh generate -g typescript -i example.yaml -o ./src/api
yarn && yarn start
Related issues/PRs
#5995 seems to solve a similar issue
Suggest a fix
Import the missing type into
DefaultApi.ts
:// TODO: better import syntax? import { BaseAPIRequestFactory, RequiredError } from './baseapi'; import {Configuration} from '../configuration'; import { RequestContext, HttpMethod, ResponseContext, HttpFile} from '../http/http'; import {ObjectSerializer} from '../models/ObjectSerializer'; import {ApiException} from './exception'; import {isCodeInRange} from '../util'; + import {Character} from '../models/Character' /** * no description */ export class DefaultApiRequestFactory extends BaseAPIRequestFactory {
The text was updated successfully, but these errors were encountered: