swagger-api / swagger-api/swagger-codegen
[Go] Empty Struct Generated Which Should be a Typealias
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
swagger-codegen does not create a correct GO representation for a OpenAPI 3.0 Model (from a schema definition) which would be ideally generated as a Go typealias.
Swagger-codegen version
This is the current version used in website: 3.0.10 (current tag)
openapi: 3.0.0
Swagger declaration file content or url
The following yaml snippet (openapi: 3.0.0) shows how the model is defined in section components/schemas:
components:
schemas:
Uint32:
minimum: 0
type: integer
format: int32
This is basically a type integer which has a special format Uint32.
Command line used for generation
The code generator has been invoked from the Export feature from the website:
GenerateServer -> GoServer
Expected :
Go:
type ModelUint32 uint32
Actual:
/*
* Nchf_ConvergedCharging
*
* ConvergedCharging Service © 2019, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* API version: 3.0.0.alpha-2
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/
package swagger
type ModelUint32 struct {
}
As you can see, this is an empty struct and can not be used in any way.
Steps to reproduce
Well, this would require to setup a basic swagger spec and include the schema in the components section, then generate the code.
Related issues/PRs
Suggest a fix/enhancement
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the GoServer generator entry point and the components/schemas handling described in the issue, using the provided OpenAPI 3.0 schema and generation steps as a reproduction. Compare the generated ModelUint32 output with the expected Go typealias and verify that scalar schemas no longer produce an empty struct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100