Skip to content

[JAVA] incorrect import mapping of alias types #3589

Closed
@bkoziak

Description

@bkoziak

[JAVA] incorrect import mapping of alias types

Description

Hi guys,

I've hit the wall trying to use importMapping together with type aliases. I'm a newbie when it comes to openapi so forgive me if I used wrong terms or something. Here's an example of what I wanted to achieve (use below yaml as a reference):

  1. I've created TypeAlias which aliases string
  2. I used TypeAlias as $ref for property typeAlias of ParentType schema
  3. I configured openapi-generator-maven-plugin to map TypeAlias to foo.bar.TypeAlias
  4. As a result typeAlias was generated as String instead of foo.bar.TypeAlias
openapi-generator version

master - 4.1.0-SNAPSHOT, 4.0.0, 3.x.x

OpenAPI declaration file content or url
openapi: 3.0.0
info:
  title: Sample API
  description: API description in Markdown.
  version: 1.0.0
paths:
  /type-alias:
    get:
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ParentType'

components:
  schemas:
    ParentType:
      title: ParentType
      type: object
      properties:
        typeAlias:
          $ref: '#/components/schemas/TypeAlias'
    TypeAlias:
      type: string
Command line used for generation

Maven plugin with following importMapping configuration:

<importMappings>
    <importMapping>TypeAlias=foo.bar.TypeAlias</importMapping>
</importMappings>
Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions