swagger-api / swagger-api/swagger-codegen
[JAXRS] Format not respected for primitive datatype Definition models
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
The format for a primitive datatype definition is not respected when referenced from other definitions or responses.
Swagger-codegen version
Originally seen in 2.3.0 but also in master
Swagger declaration file content or url
sample api.yml
swagger: '2.0'
info:
title: 'Test'
description:
version: 0.0.1
contact:
name: 'justine'
basePath: /api/
paths:
/test:
get:
operationId: test_operation
produces:
- application/json
parameters: []
responses:
'200':
description: successful operation
schema:
$ref: '#/definitions/Test'
definitions:
Test:
type: object
properties:
Long1:
$ref: "#/definitions/LongProperty"
Long2:
type: integer
format: int64
LongProperty:
type: integer
format: int64
Generated Test model class (partial)
public class Test {
@JsonProperty("Long1")
private Integer long1 = null;
@JsonProperty("Long2")
private Long long2 = null;
public Test long1(Integer long1) {
this.long1 = long1;
return this;
}
...
}
Command line used for generation
swagger-codegen generate -i api.yml -l jaxrs
Steps to reproduce
Copy paste example api.yml file
Run command line
Go to src/gen/java/io/swagger/model/Test.java and the Long1 field will be an Integer but the Long2 field is a Long.
Suggest a fix/enhancement
The format property should be respected for primitive datatype Definitions.
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 api.yml and the JAXRS generation path invoked by swagger-codegen generate -i api.yml -l jaxrs; compare the generated src/gen/java/io/swagger/model/Test.java fields for Long1 and Long2. Trace how referenced primitive definitions are mapped and verify that the referenced LongProperty produces the same Java type as the inline int64 property.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100