OpenAPITools / OpenAPITools/openapi-generator
[BUG] schema mappings discard field description / validation / etc
Open
Nobody has claimed this yet.
Issue: Bug
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Bar.java looks like this with openapi-generator-cli generate -g spring -i example.yml -o output:
/**
* The maximum value
* @return foo
*/
@Size(min = 1, max = 10)
@Schema(name = "foo", description = "The maximum value", required = false)
public String getFoo() {
return foo;
}
With the schema remapped (--schema-mappings=Foo=com.example.Foo), it's missing @Size and description:
/**
* Get foo
* @return foo
*/
@Valid
@Schema(name = "foo", required = false)
public com.example.Foo getFoo() {
return foo;
}
openapi-generator version
6.0.1
OpenAPI declaration file content or url
openapi: "3.0.0"
info:
version: 1.0.0
title: Example
license:
name: MIT
paths:
/pets:
get:
summary: List all pets
operationId: listPets
tags:
- pets
responses:
'200':
description: A paged array of pets
content:
application/json:
schema:
$ref: "#/components/schemas/Bar"
components:
schemas:
Bar:
type: object
properties:
foo:
$ref: "#/components/schemas/Foo"
Foo:
type: string
description: The maximum value
minLength: 1
maxLength: 10
Related issues/PRs
#12600
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 supplied OpenAPI YAML and the Spring generator command using --schema-mappings=Foo=com.example.Foo. Compare the generated Bar.java output with and without the mapping, focusing on the missing description and @Size annotation. Done means the remapped field retains the documented description and validation metadata.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100