[BUG] Mistype in InlineModelResolver leads to autogenerated class name instead of specified by title
Bug Report Checklist
- [x] Have you provided a full/minimal spec to reproduce the issue?
- [x] Have you validated the input using an OpenAPI validator (example)?
- [ ] Have you tested with the latest master to confirm the issue still exists?
- [x] Have you searched for related issues/PRs?
- [x] What's the actual output vs expected output?
- [ ] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
The problem occurs with following input:
components:
schemas:
Root:
type: object
additionalProperties:
title: TestValueModel
type: object
properties:
name:
type: String
I expect number of value class to be TestValueModel. Instead it is generated as RootValue.
This is happens because of mistype in InlineModelResolver :: gatherInlineModels at line 317: https://github.com/OpenAPITools/openapi-generator/blob/f145b8962d3c3bb2692841b5c093aa24a5296cde/modules/openapi-generator/src/main/java/org/openapitools/codegen/InlineModelResolver.java#L317
// Check additionalProperties for inline models
if (schema.getAdditionalProperties() != null) {
if (schema.getAdditionalProperties() instanceof Schema) {
Schema inner = (Schema) schema.getAdditionalProperties();
if (inner != null) {
String schemaName = resolveModelName(schema.getTitle(), modelPrefix + this.inlineSchemaOptions.get("MAP_ITEM_SUFFIX"));
// Recurse to create $refs for inner models
gatherInlineModels(inner, schemaName);
if (isModelNeeded(inner)) {
// If this schema should be split into its own model, do so
Schema refSchema = this.makeSchemaInComponents(schemaName, inner);
schema.setAdditionalProperties(refSchema);
}
}
}
}
instead of schema.getTitle() inner schema title inner.getTitle() should be used.
openapi-generator version
6.6.0, but bug is still in trunk
Generation Details
spring generator for Java
Steps to reproduce
Related issues/PRs
Suggest a fix
instead of schema.getTitle() inner schema title inner.getTitle() should be used.
can you please file a PR with the suggested fix when you've time?