New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add examples #62
Add examples #62
Conversation
properties[propertyName] = extend({}, | ||
this.buildDataType(oldProperty, true), | ||
{description: oldProperty.description} | ||
allowedProperties |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need such big changes.
Just add example: undefinedIfEmpty(oldProperty.example)
in two places
Here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will that make example key be present even if it were undefined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, only if it proper value.
For example it also skip null and empty string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can see check here https://github.com/apigee-127/swagger-converter/blob/master/index.js#L824
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That will put an undefined value for the example key, no?
On Thursday, November 19, 2015, Ivan Goncharov notifications@github.com
wrote:
In index.js
#62 (comment)
:properties[propertyName] = extend({}, this.buildDataType(oldProperty, true),
{description: oldProperty.description}
allowedProperties
You can see check here
https://github.com/apigee-127/swagger-converter/blob/master/index.js#L824—
Reply to this email directly or view it on GitHub
https://github.com/apigee-127/swagger-converter/pull/62/files#r45416240.
Steve Bussey •SalesLoft
•Software Engineer
e steve.bussey@salesloft.com w salesloft.com
http://salesloft.com/?v=1&utm_expid=76406993-1.E5ncJhwyTAW9uGaR1WdBTA.1?utm_source=Email-Signature-Rescue&utm_medium=Email-Signature&utm_campaign=Email-Signature-Rescue
a 3423 Piedmont Rd NE, Atlanta, GA 30305
[image: Facebook] https://www.facebook.com/SalesLoft [image: Twitter]
https://twitter.com/SalesLoft [image: Linkedin]
https://www.linkedin.com/company/salesloft [image: wordpress]
http://blog.salesloft.com/blog/ [image:
http://salesloft.com/prospector/#video]
http://salesloft.com/prospector/#video [image: Software Engineer Logo]
http://salesloft.com/?v=1&utm_expid=76406993-1.E5ncJhwyTAW9uGaR1WdBTA.1?utm_source=Email-Signature-Rescue&utm_medium=Email-Signature&utm_campaign=Email-Signature-Rescue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sb8244 Sorry I made mistake. You don't need undefinedIfEmpty
wrapper.
simply example: oldProperty.example
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extend
function checks values internally, see: https://github.com/apigee-127/swagger-converter/blob/master/index.js#L798
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We convert a lot of optional fields so to check each of them individually mean huge code bloat.
At least 3 lines instead of single one.
@IvanGoncharov please review and let me know when it's good to merge. |
} | ||
} | ||
}, | ||
"parameters": [{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sb8244
You have custom formatting of ouput file so it require manual fixing each time we change something in the lib.
Please uncomment this lines run test and copy complex-models.json-converted
file.
@sb8244 Also can you also squash your changes into one commit, it will simplify history. |
I would be happy to squash |
Example property under swagger 1.2 model is kept in the swagger 2.0 definition If a swagger 1.2 model has the example key, it will be transferred to the swagger 2.0 definition
@IvanGoncharov I have squashed & fixed the json formatting |
Thank you! 😀 |
Thank you both! I'll PR again if I find any weirdness. Flow right now is swagger-docs ruby bindings to swagger 1.2 json files, then running a conversion script to go from 1.2 to 2.0. From there, pipe it into a themed swagger-ui. |
@sb8244 SwaggerUI has native support for 1.2(it has its own converter). |
I have been using https://github.com/jensoleg/swagger-ui which is a much more production ready documentation visual than the default theme. This theme does support 1.2, but the examples section isn't processed unless it's in 2.0, because of the change from model to definitions. |
This adds support for the example property on swagger 1.2 models and model properties. They will map over the the identical field in swagger 2.0 definitions.
#61