Skip to main content

Example 5. Inheritance

JSight API 0.3OpenAPI 3.0.1 (Swagger)
JSIGHT 0.3

TYPE @pet
{
"id" : 123,
"name": "Tom"
}

TYPE @cat
{ // {allOf: "@pet"}
"likesMouses": true
}

TYPE @dog
{ // {allOf: "@pet"}
"teethSize": "big" // {enum: ["big", "small"]}
}

This example shows how simple it is to inherit one type from another in JSight using the rule allOf.

Learn more: JSight Schema Specification. Rule "allOf".

Star us on GitHub — it motivates us a lot!

openapi: 3.0.3
info:
title: ""
version: ""
paths: {}
components:
schemas:
Pet:
type: object
required: [id, name]
properties:
id:
type: integer
example: 123
name:
type: string
example: "Tom"
Cat:
allOf:
- $ref: '#/components/schemas/Pet'
- type: object
required: [likesMice]
properties:
likesMice:
type: boolean
Dog:
allOf:
- $ref: '#/components/schemas/Pet'
- type: object
required: [teethSize]
properties:
teethSize:
type: string
enum: ["big", "small"]