Skip to content

[BUG] schema mappings are not applied to parameters schemas #12885

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

Schema mappings don't seem to be applied to schemas referenced from an endpoint's parameters. With this:

openapi-generator-cli generate -g java -i example.yml -o output --schema-mappings=Limit=com.example.Limit

the generated code still uses a raw Integer rather than com.example.Limit:

public List<Pet> listPets(Integer limit) throws ApiException {

In contrast, --schema-mappings=Pet=com.example.Pet works as expected:

public List<com.example.Pet> listPets(Integer limit) throws ApiException {
openapi-generator version

6.0.1

OpenAPI declaration file content or url

This is a modified version of the pet store example, with the limit query parameter extracted into a separate schema:

openapi: "3.0.0"
info:
  version: 1.0.0
  title: Swagger Petstore
  license:
    name: MIT
servers:
  - url: http://petstore.swagger.io/v1
paths:
  /pets:
    get:
      summary: List all pets
      operationId: listPets
      tags:
        - pets
      parameters:
        - name: limit
          in: query
          description: How many items to return at one time (max 100)
          required: false
          schema:
            $ref: "#/components/schemas/Limit"
      responses:
        '200':
          description: A paged array of pets
          content:
            application/json:    
              schema:
                $ref: "#/components/schemas/Pets"
components:
  schemas:
    Limit:
      type: integer
      format: int32
    Pet:
      type: object
      required:
        - id
        - name
      properties:
        id:
          type: integer
          format: int64
        name:
          type: string
        tag:
          type: string
    Pets:
      type: array
      items:
        $ref: "#/components/schemas/Pet"
Related issues/PRs

#12600

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    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