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 generated and according to the log:
[INFO] Model MyModel not generated since it's a free-form object
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 openapi-generator version
4.1.3
components:
schemas:
MyModel:
type: object
additionalProperties:
type: object
example:
Sheet 1!A1: 0
Sheet 1!A2: a text
mvn clean generate-resources
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>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>${openapi-generator-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>
<generatorName>typescript-angular</generatorName>
<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>
I was expecting a typescript similar to:
export interface MyModel {
[key: string]: any;
}
I guess this is not specific to the typescript-angular generator but a general issue.
@marcocunha would you like to implement a fix?
I can confirm this is a general typescript wide issue. My guess is somewhere in the DefaultCodegen class file
It is actually true for all templates:
https://github.com/OpenAPITools/openapi-generator/blob/3adfdfafea183dfc4a1edf9a8df42f68657f662c/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java#L448-L450
Not sure what the intention was, but maybe this should also be handled with generateAliasAsModel, as it鈥檚 an alias for object.
I would love to see a soltution for the bug! Any Progress so far?