Skip to main content

Example 3. Schema

JSight API 0.3OpenAPI 3.0.1 (Swagger)
JSIGHT 0.3

TYPE @cat
{
"id" : 123,
"name" : "Tom",
"birthday": "2006-01-02", // {type: "date" }
"email" : "tom@cats.com", // {type: "email"}
"website" : "http://tom.cats.com", // {type: "uri" }
"salary" : 13.23, // {precision: 2 }
"friends" : [ // {maxItems: 10 }
@cat
],
"bestFriend": @cat, // {optional: true}
"size" : "XL" // {enum: ["M", "L", "XL"]}
}

Details that are not obvious from the example of valid data are provided in small JSON objects in C-like comments. This approach allows you to write data schemas of any complexity, while keeping them compact and intuitive.

More about JSight Schema: Quick Tutorial. Lesson 4. Schemas.

Star us on GitHub — it motivates us a lot!

openapi: 3.0.3
info:
title: ""
version: ""
paths: {}
components:
schemas:
Cat:
type: object
required:
- id
- name
- birthday
- email
- website
- salary
- friends
- size
properties:
id:
type: integer
minimum: 0
example: 123
name:
type: string
example: "Tom"
birthday:
type: string
format: date
example: 2006-01-02
email:
type: string
format: email
example: "tom@cats.com"
website:
type: string
format: uri
example: "http://tom.cats.com"
salary:
type: number
multipleOf: 0.01
example: 13.23
friends:
type: array
items:
$ref: '#/components/schemas/Cat'
bestFriend:
$ref: '#/components/schemas/Cat'
size:
type: string
enum: [M, L, XL]
example: XL