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
  • Merge requests
  • !4182

java: allow aliased types to have custom mappings

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/fabiokung/mapping-ref-string into master Oct 19, 2019
  • Overview 0
  • Commits 2
  • Pipelines 0
  • Changes 5

Created by: fabiokung

Fixes #2858. UPDATE: I was wrong and misundertood the code, this PR does not fix the issue, but https://github.com/OpenAPITools/openapi-generator/pull/4182#issuecomment-546092134 discusses an alternative on how to accomplish the same. I'd still consider the original issue to be a bug, it should be possible to define type mappings for any type definition in the spec.

This will allow kubernetes-client-java to switch to openapi-generator (kubernetes-client/java#709).

The kubernetes API swagger spec has types aliased to primitive types, e.g.:

    "intstr.IntOrString": {
      "description": "IntOrString is a type that can hold an int32 or a string.  When used in JSON or YAML marshalling and unmarshalling, it produces or consumes the inner type.  This allows you to have, for example, a JSON field that can accept a name or number.",
      "format": "int-or-string",
      "type": "string"
    },

However, these types need to be mapped to custom types in the Java client, so we can have custom serialization for them. The generator is being invoked with the following options:

  <type-mappings>intstr.IntOrString=IntOrString,resource.Quantity=Quantity</type-mappings>
  <import-mappings>IntOrString=io.kubernetes.client.custom.IntOrString,Quantity=io.kubernetes.client.custom.Quantity</import-mappings>

Without changes in this PR, type-mappings gets ignored, since IntOrString is first resolved to its alias (string), before mappings are evaluated.

cc @wing328 @brendandburns @yue9944882

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/fabiokung/mapping-ref-string