Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #7905
Closed
Open
Issue created Nov 09, 2020 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[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
  1. Generate classes
  2. Look inside Pet class. Size annotations are missing on getters
Related issues/PRs
Suggest a fix
Assignee
Assign to
Time tracking