json-schema-to-openapi-schema icon indicating copy to clipboard operation
json-schema-to-openapi-schema copied to clipboard

Upgrading to support examples from draft-06

Open Solosneros opened this issue 6 years ago • 11 comments

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.

Solosneros avatar Jan 31 '19 09:01 Solosneros

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.

philsturgeon avatar Feb 08 '19 21:02 philsturgeon

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.

sixlive avatar Feb 09 '19 12:02 sixlive

@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. :)

Solosneros avatar Feb 11 '19 07:02 Solosneros

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.

sixlive avatar Feb 11 '19 18:02 sixlive

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

Solosneros avatar Mar 27 '19 07:03 Solosneros

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 avatar Mar 27 '19 08:03 philsturgeon

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

philsturgeon avatar Mar 27 '19 08:03 philsturgeon

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

mribichich avatar Jul 11 '19 16:07 mribichich

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

Solosneros avatar Jan 20 '20 12:01 Solosneros

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

philsturgeon avatar Jan 20 '20 13:01 philsturgeon

Sad to hear. Thanks for the fork!

Solosneros avatar Jan 20 '20 19:01 Solosneros