-
-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Using the petstore.yaml sample file, the provided enum is not reflected in the Go generated files
Pet:
title: a Pet
description: A pet for sale in the pet store
type: object
required:
- name
- photoUrls
properties:
id:
type: integer
format: int64
category:
$ref: '#/components/schemas/Category'
name:
type: string
example: doggie
photoUrls:
type: array
xml:
name: photoUrl
wrapped: true
items:
type: string
tags:
type: array
xml:
name: tag
wrapped: true
items:
$ref: '#/components/schemas/Tag'
status:
type: string
description: pet status in the store
enum:
- available
- pending
- sold
the Pet structure is generated this way:
// Pet A pet for sale in the pet store
type Pet struct {
Id *int64json:"id,omitempty"
Category *Categoryjson:"category,omitempty"
Name stringjson:"name"
PhotoUrls []stringjson:"photoUrls"
Tags *[]Tagjson:"tags,omitempty"
// pet status in the store
Status *stringjson:"status,omitempty"
}
It implies to add manually files to reflect these enums, this decreases the interested of such generated files, hard to maintain
openapi-generator version
latest master version (does not work with previous versions as well to my knowledge)
commit 6c40192 (HEAD -> master, origin/master, origin/HEAD)
Date: Mon May 24 07:01:16 2021 +0200
OpenAPI declaration file content or url
Generation Details
./run-in-docker.sh generate -i petstore.yaml -g go -o /gen/out/petstore --skip-validate-spec --package-name=ps -c config.yaml
config.yaml:
additionalProperties:
generateInterfaces: "true"
enumClassPrefix: "true"
isGoSubmodule: "true"
Steps to reproduce
generate the go files using the provided generation details and the petstore.yaml file
Related issues/PRs
This is related to this issue: #8937
but for the golang language
Suggest a fix
Instead of using a *string, generate a new dedicated type and set the possible values accordingly