Is there a library to convert json schema to Swagger doc?

11,577 views
Skip to first unread message

Michelle Sanver

unread,
Jun 5, 2015, 3:34:01 AM6/5/15
to swagger-sw...@googlegroups.com
Hi everyone,

A search in this group and a google search I can't find a library to convert json schema to Swagger doc which is a usecase that we have. To avoid doing duplicate work if it already exists I'm asking here first, does it exist?

If not I'll create it.

Thanks!

Sincerely,
Michelle Sanver

Ron Ratovsky

unread,
Jun 5, 2015, 10:23:25 AM6/5/15
to swagger-sw...@googlegroups.com
Not quite sure what you're looking for. JSON Schema is used to describe JSON structures.
Can you clarify what you'd trying to do?

--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
-----------------------------------------
http://swagger.io
https://twitter.com/SwaggerApi
-----------------------------------------

Michelle Sanver

unread,
Jun 5, 2015, 10:28:03 AM6/5/15
to swagger-sw...@googlegroups.com
I have a message oriented middleware, what I am trying to do is document all the messages that you can send, which we have in a folder with json schemas, this is one of our schemas, they are all very simple messages:

"{
    "$schema": "http://json-schema.org/draft-04/schema#",
"title": "Cumulus coupon",
"description": "Send a message about a user that got a new coupon.",
"type": "object",
"example": {
"cumulus-number": "2099412220012",
"coupon-id": "1234567"
},
"properties": {
"cumulus-number": {
"description": "Cumulus number",
"type": "string",
"pattern": "^2099[0-9]{9}$"
},
"coupon-id": {
"description": "A coupon information ID. See https://api.migros.ch/coupons.json",
"type": "string"
}
},
"required": ["cumulus-number", "coupon-id"],
"additionalProperties": false
}

If I from that folder could generate swagger docs, where you can also use the sandbox to send the message from the “example” part in the schema it would be pretty neat and easy documentation for everyone to use, from a google search I could not find anything that does what I want, so currently in the process to implement it myself. 
You received this message because you are subscribed to a topic in the Google Groups "Swagger" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/swagger-swaggersocket/1MrITh-Kcdg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to swagger-swaggers...@googlegroups.com.

Ron Ratovsky

unread,
Jun 5, 2015, 10:36:38 AM6/5/15
to swagger-sw...@googlegroups.com
Swagger uses an extended subset of JSON Schema to describe its models. Assuming you follow the same subset, you can just take the schema you have as-is and use them as part of the Swagger document (you can even $ref your own hosted files). "example" is actually not part of JSON Schema, but we happen to have that as an extension as well which translates to the same meaning. I have no way of knowing if your schema follows the limitations we impose, but you can read more about those here - https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#schemaObject.

Beyond that, you'd still need to document your end points. Swagger is not just about the models but the operations themselves. I assume those are not described using a JSON Schema as well, and you'd have to describe those manually. I think some MOMs have a way of generating a Swagger definition, but not sure regarding the one you use.

Michelle Sanver

unread,
Jun 5, 2015, 10:42:58 AM6/5/15
to swagger-sw...@googlegroups.com
Thank you! That helps me a *lot*, we are using our own custom MOM built on top of Symfony2 and rabbitMQ, the endpoints are already configured was “only” missing the documentation itself, with the models and description. 

Ron Ratovsky

unread,
Jun 5, 2015, 10:44:23 AM6/5/15
to swagger-sw...@googlegroups.com
Well, the spec itself should provide you the details. If you want to combine it all, you can use the editor for easier generation.

Suraj ES

unread,
Aug 28, 2016, 7:25:21 AM8/28/16
to Swagger
was trying something.. checkit out if its usefull to you https://swagger-toolbox.firebaseapp.com/
Reply all
Reply to author
Forward
0 new messages