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
  • #2858
Closed
Open
Issue created May 10, 2019 by Administrator@rootContributor

[BUG] Generator 3.3.4 does not respect Java import mapping for string refs

Created by: chrylis

Description

I am trying to map a custom data type to a JSON string-valued property (more or less equivalent to a custom format); Jackson will transparently handle the conversion for me in Java. However, the generator does not observe user custom mappings when a $ref type is marked as a string.

openapi-generator version

This behavior is observed with 3.3.4

OpenAPI content
# correctly identifies that EntityIdentifier is a string and produces a Map<String, String>,
# but does not use the LSP to use a custom data type
components:
  schemas:
    EntityIdentifier:
      type: string
      pattern: '^\w+:[\w\d-]+$'
    ResolveExpressionRequest:
      type: object
      properties:
        expression:
          type: string
          minLength: 1
        rootObject:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/EntityIdentifier'
# Generates a Map<String, EntityIdentifierDto>
components:
  schemas:
    EntityIdentifier:
      type: object
    ResolveExpressionRequest:
      type: object
      properties:
        expression:
          type: string
          minLength: 1
        rootObject:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/EntityIdentifier'
Command line used for generation

Invoked via Maven plugin:

<plugin>
    <groupId>org.openapitools</groupId>
    <artifactId>openapi-generator-maven-plugin</artifactId>
    <version>3.3.4</version>
    <executions>
        <execution>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <inputSpec>${project.basedir}/src/main/openapi/openapi.yaml</inputSpec>
                <generatorName>java</generatorName>
                <importMappings>EntityIdentifier=foo.EntityIdentifierDto</importMappings>
                <configOptions>
                  <library>resttemplate</library>
                  <java8>true</java8>
                </configOptions>
            </configuration>
        </execution>
    </executions>
  </plugin>
Steps to reproduce

As above, a $ref that is of type: string does not get overridden by the custom mapping.

Assignee
Assign to
Time tracking