swagger-api / swagger-api/swagger-codegen
[Typescript-Angular] Wrong import generated with request having schema with oneOf
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
The generated code for a path response having schema with oneOf generates a wrong file import
Swagger-codegen version
3.0.34, 3.0.35
Swagger declaration file content or url
openapi: 3.0.0
info: {
title: 'abc',
version: "1"
}
paths:
/test:
get:
responses:
default:
description: 'abc'
content:
application/json:
schema:
items:
oneOf:
- $ref: '#/components/schemas/ClassA'
- $ref: '#/components/schemas/ClassB'
components:
schemas:
ClassA:
type: object
ClassB:
type: object
Command line used for generation
java -jar swagger-codegen-cli-3.jar generate -i ${api.url} -l typescript-angular -o ./ --additional-properties ngVersion=13.3.0
Steps to reproduce
Generate the client using the typescript-angular generator, see that it imports { ClassAClassB } from '../model/classAClassB'; without actually generating that class.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the typescript-angular generator and reproduce the issue using the OpenAPI YAML and the documented swagger-codegen CLI command. Inspect how the response schema containing oneOf is converted into imports and model names; done means the generated client imports only classes that are actually generated, including ClassA and ClassB.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, java, typescript
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100