swagger-api / swagger-api/swagger-codegen
[TypeScript] Free-Form object being generated incorrectly
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
I'm trying to generate the typescript models, based on the schemas defined in the YAML file, but there is a model (free-form object) that is not being properly generated and the typescript is generated like
export interface MyModel extends null<String, any> {
[key: string]: any;
}
while I was expecting something like:
export interface MylModel {
[key: string]: any;
}
Is relevant to mention that this problem started happening after the migration from Swagger 2.x version to OpenAPI 3.0 and i also started using this new Swagger-codegen version
Swagger-codegen version
3.0.11
Swagger declaration file content or url
components:
schemas:
MyModel:
type: object
additionalProperties:
type: object
example:
Sheet 1!A1: 0
Sheet 1!A2: a text
Command line used for generation
mvn clean generate-resources
Steps to reproduce
Using a valid open API 3.0 YAML file, declare the schema referred above and generate the typescript model using the following pom configuration:
<plugin>
<groupId>io.swagger.codegen.v3</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>${swagger-codegen-maven-plugin.version}</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${basedir}/../schema/api.yaml</inputSpec>
<output>${basedir}/src/app/shared/api</output>
<language>typescript-angular</language>
<generateApis>false</generateApis>
<generateSupportingFiles>true</generateSupportingFiles>
<generateModelDocumentation>false</generateModelDocumentation>
<generateModelTests>false</generateModelTests>
<generateSupportingFiles>false</generateSupportingFiles>
<generateAliasAsModel>true</generateAliasAsModel>
<modelPackage>models</modelPackage>
</configuration>
</execution>
</executions>
</plugin>
Related issues/PRs
Suggest a fix/enhancement
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
Run the provided mvn clean generate-resources reproduction with the OpenAPI 3 YAML schema and inspect the generated TypeScript model. Compare MyModel with the expected free-form object shape; done means generation no longer emits the invalid null<String, any> extension and produces the index signature shown in the report.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, yaml
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100