Bug Report Checklist
Description
After upgrading an API specification from OpenAPI 3.0.x to 3.1.0, model naming
changes when response schemas are defined in external files and referenced via $ref.
Instead of reusing the referenced schema name, openapi-generator generates
operation-based response models such as:
- GetItems200Response
- GetItems200ResponseDataInner
This occurs even when the referenced schema is explicitly named and reusable.
Related OpenAPI Specification discussion:
👉 <LINK TO MY OPENAPI-SPEC ISSUE>
openapi-generator version
7.16.0
OpenAPI declaration file content or url
openapi: 3.1.0
info:
title: Example API
version: 1.0.0
paths:
/items:
get:
operationId: getItems
responses:
200:
description: OK
content:
application/json:
schema:
$ref: schemas/common.yaml#/components/schemas/ListResponse
External schema (schemas/common.yaml):
components:
schemas:
ListResponse:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/Item'
total:
type: integer
required:
- data
- total
Item:
type: object
properties:
id:
type: string
name:
type: string
Generation Details
Generator: spring
Library: spring-boot
Options:
- interfaceOnly=true
- useSpringBoot3=true
- generateAliasAsModel=true
Steps to reproduce
- Define schemas in an external YAML file
- Reference the schema in a response using $ref
- Generate models using OpenAPI 3.1.0
Actual Output
GetItems200Response
GetItems200ResponseDataInner
Expected Output
Related issues
OpenApi Specification issue: OAI/OpenAPI-Specification#5181
Suggest a fix
This may not be a bug but expected behavior per OpenAPI 3.1.
Possible improvements:
- Document this behavior clearly
- Provide a generator option to prefer referenced schema names when resolvable
- Clarify recommended structuring for external schema reuse in 3.1
Bug Report Checklist
Description
After upgrading an API specification from OpenAPI 3.0.x to 3.1.0, model naming
changes when response schemas are defined in external files and referenced via $ref.
Instead of reusing the referenced schema name, openapi-generator generates
operation-based response models such as:
This occurs even when the referenced schema is explicitly named and reusable.
Related OpenAPI Specification discussion:
👉 <LINK TO MY OPENAPI-SPEC ISSUE>
openapi-generator version
7.16.0
OpenAPI declaration file content or url
External schema (schemas/common.yaml):
Generation Details
Generator: spring
Library: spring-boot
Options:
Steps to reproduce
Actual Output
Expected Output
Related issues
OpenApi Specification issue: OAI/OpenAPI-Specification#5181
Suggest a fix
This may not be a bug but expected behavior per OpenAPI 3.1.
Possible improvements: