swagger-api / swagger-api/swagger-codegen
[general] date examples are converted and output as date-time in generated json
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Using yaml input, we among other things also generate json.
Adding an example to a date results in the date being parsed and serialized back to string as date-time
Swagger-codegen version
2.2.3, generator cxf-jaxrs-client
Swagger declaration file content or url
yaml input
swagger: '2.0'
info:
title: Member
version: '2.0'
basePath: /education-group/v2
paths:
/:
get:
responses:
'200':
description: members
schema:
$ref: '#/definitions/Member'
definitions:
Member:
type: object
properties:
endDate:
type: string
format: date
example: 2117-01-01
json output
"endDate" : {
"type" : "string",
"format" : "date",
"example" : "2117-01-01T00:00:00.000+0000",
}
Command line used for generation
swagger-codegen-cli doesn't support json, but html works as well so this seems to be a general problem rather than java or html
java -jar swagger-codegen-cli.jar generate -i input.yaml -l html
Steps to reproduce
- save input.yaml from the issue
- java -jar swagger-codegen-cli.jar generate -i input.yaml -l html
- grep '"endDate"' index.html
"endDate" : "2117-01-01T00:00:00.000+0000"
Related issues/PRs
N/A
Suggest a fix/enhancement
Either parse and return date as date instead of date-time, or simply treat the example an opaque string.
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
Reproduce the issue with input.yaml using swagger-codegen-cli.jar and the cxf-jaxrs-client generator, then inspect the generated index.html output for the endDate example. The fix is complete when the date example remains "2117-01-01" or is represented as a date rather than being converted to date-time.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, yaml
- Domain
- api, documentation
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100