[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.