Skip to main content

Example 2. User Types

JSight API 0.3OpenAPI 3.0.1 (Swagger)
JSIGHT 0.3

GET /cats // Get all cats.
200
[@cat]

GET /cats/{id} // Get a cat by its id.
200
@cat

TYPE @cat // Type “Cat”.
{
"id" : 123, // ID of the cat.
"name": "Tom" // Name of the cat.
}

Pay attention to how convenient it is to work with user types in JSight API. The type name is simply inserted where the type should be in the data schema. Everything is the same as in conventional programming languages.

More about user types: Quick Tutorial. Lesson 2. User types.

Star us on GitHub — it motivates us a lot!

openapi: 3.0.3
info:
title: ""
version: ""
paths:
/cats:
get:
summary: Get all cats.
responses:
200:
description: ""
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Cat'
/cats/{id}:
get:
summary: Get a cat by its id.
parameters:
- name: id
in: path
required: true
schema: {}
responses:
200:
description: ""
content:
application/json:
schema:
$ref: '#/components/schemas/Cat'
components:
schemas:
Cat:
description: Type “Cat”.
type: object
required: [id, name]
properties:
id:
description: ID of the cat.
type: integer
minimum: 0
example: 123
name:
description: Name of the cat.
type: string
example: "Tom"