[BUG] [Java][Spring] Model composition does not work for string type
Created by: yklymenko
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
It is sometimes useful to have a base type which is derived from string with all constraints, refer this type using "ref" syntax and change just the description. The problem is that generation does not work correctly for the case shown below. @Size annotation will be not generated as expected.
openapi-generator version
I use 5.0.0-beta2 in my test
OpenAPI declaration file content or url
openapi: 3.0.0
info:
description: test
version: 1.0.0
title: OpenAPI Petstore
license:
name: Apache-2.0
url: 'https://www.apache.org/licenses/LICENSE-2.0.html'
paths:
/pet:
post:
description: ''
responses:
'200':
description: successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
components:
schemas:
Pet:
title: a Pet
description: A pet for sale in the pet store
type: object
properties:
test1:
allOf:
- $ref: '#/components/schemas/StringMinMax'
- description: "Property one description"
test2:
allOf:
- $ref: '#/components/schemas/StringMinMax'
- description: "Property two description"
StringMinMax:
type: string
minLength: 1
maxLength: 5
Generation Details
java -jar openapi-generator-cli-5.0.0-beta2.jar generate -i petstore.yaml -g spring
Steps to reproduce
- Generate classes
- Look inside Pet class. Size annotations are missing on getters