yamlinc
yamlinc copied to clipboard
yamlinc changes example dates when merging
Here's a piece of a request definition in one of my source files:
- name: date
description: The date
in: path
required: true
schema:
type: string
format: date
example: 2019-12-25
And here's the same section after merging with yamlinc:
- name: date
description: The date
in: path
required: true
schema:
type: string
format: date
example: '2019-12-25T00:00:00.000Z'
Note how the example date in the last line has been changed from just the date to a full date and time format, which is not what I want in this case. Is there a way to prevent this from happening?
@StephenNay parsing dates is a known problem of YAML, take a look at this https://github.com/nodeca/js-yaml/issues/161
to prevent this, my best choice is quoting as a string the date, but if you will work with the custom schema you can do using --schema
argument https://github.com/javanile/yamlinc#use-an-external-schema
See more:
- http://blogs.perl.org/users/tinita/2018/01/introduction-to-yaml-schemas-and-tags.html
- https://github.com/trek10inc/cloudformation-schema-js-yaml
I'm also experiencing this issue but with strings that are not in a specific format: In my base file:
phone:
type: string
example: 0102030405
The swagger.inc.yml:
phone:
type: string
example: 17314053
What's weird is that I have a postal_code declared the same way:
postal_code:
type: string
example: 33130
And in the swagger.inc.yml file the postal_code has the correct value