How Do I connect swagger YMAL to jsonschema

1,316 views
Skip to first unread message

刘晓光

unread,
Sep 6, 2015, 4:08:09 AM9/6/15
to Swagger
Dear all,

swagger DSL  http://editor.swagger.io/#/  

our team are using swagger DSL to generate  code  while as a tester I wan't to use json-schema DSL and json-schema-validator to validate schema of responses. https://github.com/fge/json-schema-validator

The question is ,how can I map a swagger DSL definition to a json chema DSL definition?

Thanks a lot !

Lucas

Ron Ratovsky

unread,
Sep 6, 2015, 4:23:07 AM9/6/15
to Swagger
Lucas, Swagger uses an extended subset of JSON Schema do describe models. If you describe something outside that scope using JSON Schema, it will not be supported by Swagger.

--
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
-----------------------------------------

刘晓光

unread,
Sep 6, 2015, 5:42:59 AM9/6/15
to Swagger
hi Ron,
   Thanks for you answer. now I get swagger use a subset of json schema,that's very helpful.  I wonder is there some tools or program that can convertiing  swagger DSL to Json Schema DSL.

i.e. 

can convert  Swagger DSL:

paths:
  /products:
    get:
      summary: Product Types
      description: |
        The Products endpoint returns information about the *Uber* products
        offered at a given location. The response includes the display name
        and other details about each product, and lists the products in the
        proper display order.
      parameters:
        - name: latitude
          in: query
          description: Latitude component of location.
          required: true
          type: number
          format: double
        - name: longitude
          in: query
          description: Longitude component of location.
          required: true
          type: number
          format: double



 to Json Schema DSL:


{
	"title": "Product Schema",
	"type": "object",
	"properties": {
		"latitude": {
			"type": "string"
		},
		"longtitude": {
			"type": "string"
		}
		
	},
	"required": ["latitude", "longtitude"]
}


在 2015年9月6日星期日 UTC+8下午4:23:07,Ron写道:
Lucas, Swagger uses an extended subset of JSON Schema do describe models. If you describe something outside that scope using JSON Schema, it will not be supported by Swagger.
On Sun, Sep 6, 2015 at 11:08 AM, 刘晓光 <lxg...@gmail.com> wrote:
Dear all,

swagger DSL  http://editor.swagger.io/#/  

our team are using swagger DSL to generate  code  while as a tester I wan't to use json-schema DSL and json-schema-validator to validate schema of responses. https://github.com/fge/json-schema-validator

The question is ,how can I map a swagger DSL definition to a json chema DSL definition?

Thanks a lot !

Lucas

--
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-swaggersocket+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Ron Ratovsky

unread,
Sep 6, 2015, 5:51:04 AM9/6/15
to Swagger
That's not really a direct translation there - you're converting two independent properties into one object.
I don't know of any tool that does that, but that doesn't mean there isn't one.

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
-----------------------------------------

--
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.

qiang....@gmail.com

unread,
Oct 19, 2015, 2:49:39 AM10/19/15
to Swagger
Hi Mr Lucas,


Please follow the below steps to convert yaml to json, or convert json to yaml:
2. remove the current content in the left panel(it is default for Uber).
3. paste your yaml file content into the left panel, make sure there is no errors with your yaml.
4. click on "File" at the left top of the menu bar, the go to "Download json" you will get a converted json file maps to the yaml file.
5. do the same way to paste json and download yaml to convert json to yaml.
Message has been deleted

qiang....@gmail.com

unread,
Oct 19, 2015, 2:53:40 AM10/19/15
to Swagger
I think Lucas is asking for converting yaml file to json file, and swagger editor does has this function to support it.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



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

--
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-swaggersocket+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages