Nested Definition of Primitive Types Generate Empty Classes
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- java
- Domain
- backend-api-design, devtools
Research direction
Reproduce the issue with the supplied petstore.yaml and the swagger-codegen CLI command, then compare Pet.java and StringType.java with the expected Java String property. Start by reviewing the prior fix for #5382 and its primitive-alias detection. Done means nested primitive aliases such as stringType generate the standard Java primitive wrapper rather than an empty class.
Written by the indexing model from the issue text.
Description
Description
Nested definitions of a primitive type (e.g. string, number, integer) end up generating empty classes (Java).
Essentially, this is the same issue as #5382, except that these definitions are nested more than 1 layer deep.
Swagger-codegen version
2.3.0-SNAPSHOT, master
Swagger declaration file content or url
swagger: "2.0"
info:
version: 1.0.0
title: Swagger Petstore
paths:
/pet:
get:
responses:
"200":
description: Expected response to a valid request
schema:
$ref: '#/definitions/Pet'
definitions:
Pet:
properties:
name:
$ref: "#/definitions/stringType"
stringType:
$ref: "#/definitions/string"
string:
type: string
Generated code: model.zip
Pet.java'snameproperty references aStringTypeclassStringType.javais an empty class
Expected code:
Pet.java'snameproperty should be a standard JavaString
Command line used for generation
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
-i petstore.yaml \
-l spring \
-o zzzzz
Also generated via http://editor.swagger.io , with the same results.
Steps to reproduce
Any nesting of primitive types that is more than 1 level will reproduce this. Also occurs for other primitive types such as number, integer, etc.
Related issues/PRs
#5382
Suggest a fix/enhancement
Not familiar with the codebase, but my guess is that the prior fix for #5382 @bbdouglas (which added detection for whether a JSON node is an alias for another type) may need to be updated to recurse into itself to check for deeper nesting of these aliases.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
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.
More from swagger-api/swagger-codegen
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
swagger-api/swagger-codegen#12755 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
swagger-api/swagger-codegen#12445 ·
-
security vulnerability
Difficulty 1/5 Under an hour Newbie friendliness 62/100
swagger-api/swagger-codegen#11942 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
swagger-api/swagger-codegen#11812 · 1 reaction ·
-
security vulnerability
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
swagger-api/swagger-codegen#11594 ·
All issues in swagger-api/swagger-codegen
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
use-agent-os/agent-os#3276 ·
-
good first issue refactor
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
[6.x]: "Cannot use object of type stdClass as array" loading Users index (regression of #19182) Open
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
area/sessions comp/agent P2 tool/skills type/perf
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
NousResearch/hermes-agent#117788 ·