Skip to content

[BUG] schema mappings discard field description / validation / etc #12886

@Gama11

Description

@Gama11

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions