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
  • #3941
Closed
Open
Issue created Sep 23, 2019 by Administrator@rootContributor

[BUG] [Golang] Integer enum types values are quoted

Created by: jpascualsana

Description

When we generate a Go code for our API wrapper we get the Integer enums as string values causing problems talking with the API.

If you generate an enum like:

components:      
    schemas:        
        RsGxsCircleType:
            type: integer
            enum:
                    - 0

It generate this model:

type RsGxsCircleType int32

// List of RsGxsCircleType
const (
	UNKNOWN RsGxsCircleType = "0"
)

Where the "0" should be 0. As it is quoted, the JSON API call gets an string instead of an integer.

openapi-generator version
➜ openapi-generator version
4.0.3
OpenAPI declaration file content or url
openapi: 3.0.0
info:
    title: RetroShare OpenApi wrapper
    version: 0.0.1
    description: RetroShare OpenApi wrapper generated using Doxygen documentation
    license:
        name: AGPLv3
servers:
    - url: http://127.0.0.1:9092/

paths:

    /rsGxsForums/createForumV2:
        post:
            operationId: RsGxsForumsCreateForumV2
            summary: Create forum.  
            
            responses:
                '200':
                    description: "Good Response"
                    content:
                        application/json:
                            schema:
                                $ref: '#/components/schemas/RespRsGxsForumsCreateForumV2'
                        

components:      
    schemas:        
        RsGxsCircleType:
            type: integer
            enum:
                
                    - 0
                    - 1
                    - 2
                    - 3
                    - 4
                    - 5
                    - 6
            x-enum-varnames:
                
                    - UNKNOWN
                    - PUBLIC
                    - EXTERNAL
                    - NODES_GROUP
                    - LOCAL
                    - EXT_SELF
                    - YOUR_EYES_ONLY
        RespRsGxsForumsCreateForumV2:
            type: object
            properties:
                retval:
                    type: boolean
                forumId:
                    $ref: '#/components/schemas/RsGxsCircleType'
                errorMessage:
                    type: string
Command line used for generation
openapi-generator generate -i a.yml -g go -o openapi-go-retroshare-api-wrapper
Steps to reproduce

Just get the .yml and run the command. Then take a look on model_rs_gxs_circle_type.go to see the problem.

Suggest a fix

If the enum type is integer just be careful to do not put quotes.

Assignee
Assign to
Time tracking