wework / json-schema-to-openapi-schema

A little NodeJS package to convert JSON Schema to OpenAPI Schema Objects
213 stars 44 forks source link

Upgrading to support examples from draft-06 #20

Open Solosneros opened 5 years ago

Solosneros commented 5 years ago

We want to convert JSON Schema to OAI 3.0. Your package seems to be the perfect solution for us. Everything works perfectly with the exception of examples which have been added in Draft-06. Is there any possibility to add the feature to convert examples of JSON Schema to example of OAI 3.0? E.g. only converting the first example?

"currency": { "type": [ "string", "null" ], "default": "EUR", "minLength": 3, "maxLength": 3, "title": "Currency", "description": "Currency code", "examples": [ "EUR", "GBP", "USD" ] },

If you have any other suggestions to address this problem, we would look forward to hear about them.

philsturgeon commented 5 years ago

I’m not sure what we’d do here. There’s the OpenAPI 3.0 example keyword (notice it’s singular), so we could take the first only?

Other than that you’d have to make full response body examples and they live outside of the Schema object.

sixlive commented 5 years ago

I think it could be useful to just grab the first one. If you wanted more variety you could manually add full example objects.

edit: I've worked up a possible implementation https://github.com/wework/json-schema-to-openapi-schema/compare/master...sixlive:add-draft-6-examples

edit 2: I used my fork with this branch with speccy and it resolved as expected with the first example.

Solosneros commented 5 years ago

@philsturgeon The first thing you mentioned is what I thought of.

@sixlive Thanks! From what understand from the code, that looks like something I would implement as well. I just lacked the the overview in the whole project and where to implement. :)

sixlive commented 5 years ago

After writing a bunch of schemas and working on documentation today, this is a must-have feature for me. If there is anything I can/need to do to get this moving let me know. I can open a PR ASAP.

Solosneros commented 5 years ago

Hey, still looking forward to this. I assume one would just have to merge the PR. @philsturgeon @sixlive

philsturgeon commented 5 years ago

Hey I am no longer working for WeWork so i don't have the permissions to merge this. @sixlive never worked there. :)

@djtarazona hey dude, could you merge this and cut a release?

philsturgeon commented 5 years ago

@djtarazona sorry I mean merge this: https://github.com/wework/json-schema-to-openapi-schema/pull/22

mribichich commented 5 years ago

do we have news about this? does this project still active?

Solosneros commented 4 years ago

@mribichich Just came across this issue again. It seams like the project is inactive. @djtarazona or @philsturgeon ?

philsturgeon commented 4 years ago

It seems pretty clear from this thread that WeWork is not maintaining this package. I hope my friends over there are ok, but with 1000 of the eng team being fired not so long ago I have my doubts that packages like this will be on anyones radar anymore. I've forked the repo to the OpenAPI-Contrib organization, so if anyone wants this PR it's included in v1.0.0.

npm install @openapi-contrib/json-schema-to-openapi-schema

See you over there folks: https://www.npmjs.com/package/@openapi-contrib/json-schema-to-openapi-schema

Solosneros commented 4 years ago

Sad to hear. Thanks for the fork!