swagger-api / swagger-api/swagger-codegen
[swagger 2.0][go server] validate enum function is not generated for 2-dimensional array
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
This yaml specification generates validateTestItemsEnum() correctly.
definitions:
TestObject:
type: object
properties:
test:
type: array
items:
type: string
enum: [AA, BB, CC]
But in case of 2-dimensional array, the validate function is not generated so that build error occurs.
m.validateTest2ItemsEnum undefined (type *TestObject has no field or method validateTest2ItemsEnum)
definitions:
TestObject:
type: object
properties:
test:
type: array
items:
type: array
items:
type: string
enum: [AA, BB, CC]
Of course, swagger validator does not show any errors on that.
Swagger-codegen version
version: v0.21.0
commit: 7c0fc3ee340f9d99d85573bc54a57e303a639692
Swagger declaration file content or url
Command line used for generation
swagger -q generate server --exclude-main --spec-...
Steps to reproduce
- Add array of 'string array' in yaml file and define enum values for the 'string array'.
- Generate code by swagger codegen.
- codegen is done with success but build error occurs because there's no enum validation function.
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 swagger -q generate server entry point and the Swagger 2.0 Go server generation path, using the two YAML examples in the issue to reproduce the missing validation method. Trace enum validation generation for nested arrays and confirm the generated server builds successfully with a two-dimensional string enum array.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend, devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100