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
  • #13166
Closed
Open
Issue created Aug 12, 2022 by Administrator@rootContributor

[BUG] Go Code Generator do not strip out {} in oneOf

Created by: mariotoffia

Description

The GoClientCodeGen.java do incorrectly render the typeToName. The problem seems to be in

private String typeToName(String content) {
        content = content.trim().replace("[]", "array_of_");
        content = content.trim().replace("[", "map_of_");
        content = content.trim().replace("]", "");
        return camelize(content);
    }

where the content is (in my case) map[string]interface{} and the curly braces are not stripped.

openapi-generator version

Version 6.0.1

OpenAPI declaration file content or url
DataPoint:
  oneOf:
    - type: object
    - type:
      $ref: '#/SimpleDataPoint'
SimpleDataPoint:
  properties:
    v:
      type: number
    t:
      type: integer
  required:
    - v
    - t

Will generate the following struct where the MapmapOfStringinterface{} occurs.

type DataPoint struct {
	SimpleDataPoint *SimpleDataPoint
	MapmapOfStringinterface{} *map[string]interface{}
}

(🎃As a sidenote, the anyOf (mustache template) will never even try to use #lambda.type-to-name and therefore instead it will render the map[string]interface{} *map[string]interface{}.)

Steps to reproduce

generate the above snippet

Suggest a fix

Just replace {} with empty string before camelize.

Assignee
Assign to
Time tracking