Skip to content

Instantly share code, notes, and snippets.

@kevinswiber
Last active September 7, 2022 21:02
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kevinswiber/9fe3cb1b6c007e68b4d01da43ca2f429 to your computer and use it in GitHub Desktop.
Save kevinswiber/9fe3cb1b6c007e68b4d01da43ca2f429 to your computer and use it in GitHub Desktop.
Siren definitions for Open API Specification
swagger: '2.0'
info:
title: Siren API
description: Template for a Siren API
version: '0.1.0'
schemes:
- http
- https
basePath: /
produces:
- application/vnd.siren+json
paths:
/:
get:
summary: Root
responses:
200:
description: The root of the API.
schema:
$ref: '#/definitions/RootResponse'
definitions:
RootResponse:
type: object
allOf:
- $ref: '#/definitions/Entity'
- properties:
properties:
$ref: '#/definitions/RootProperties'
RootProperties:
type: object
properties:
name:
type: string
# Siren base models
Entity:
type: object
properties:
class:
type: array
items:
type: string
entities:
type: array
items:
$ref: '#/definitions/SubEntity'
actions:
type: array
items:
$ref: '#/definitions/Action'
links:
type: array
items:
$ref: '#/definitions/Link'
SubEntity:
type: object
properties:
href:
type: string
rel:
type: array
items:
type: string
class:
type: array
items:
type: string
properties:
type: object
entities:
type: array
items:
$ref: '#/definitions/SubEntity'
actions:
type: array
items:
$ref: '#/definitions/Action'
links:
type: array
items:
$ref: '#/definitions/Link'
Action:
type: object
required:
- name
- href
properties:
class:
type: array
items:
type: string
name:
type: string
method:
type: string
href:
type: string
title:
type: string
type:
type: string
fields:
type: array
items:
$ref: '#/definitions/Field'
Field:
type: object
required:
- name
properties:
name:
type: string
type:
type: string
enum:
- hidden
- text
- search
- tel
- url
- email
- password
- datetime
- date
- month
- week
- time
- datetime-local
- number
- range
- color
- checkbox
- radio
- file
title:
type: string
value:
type: string
Link:
type: object
required:
- rel
- href
properties:
class:
type: array
items:
type: string
title:
type: string
rel:
type: array
items:
type: string
href:
type: string
type:
type: string
openapi: '3.0.0'
info:
title: Siren API
description: Template for a Siren API
version: '0.2.0'
contact:
name: Kevin Swiber
url: https://twitter.com/kevinswiber
email: kswiber+openapi@gmail.com
externalDocs:
description: The Siren specification.
url: http://sirenspec.org
schemes:
- http
- https
basePath: /
paths:
/:
get:
summary: Root
responses:
'200':
description: The root of the API.
content:
'application/vnd.siren+json':
schema:
$ref: '#/definitions/RootResponse'
components:
definitions:
RootResponse:
type: object
allOf:
- $ref: '#/definitions/Entity'
- properties:
properties:
$ref: '#/definitions/RootProperties'
RootProperties:
type: object
properties:
name:
type: string
# Siren base models
Entity:
type: object
properties:
class:
type: array
items:
type: string
entities:
type: array
items:
$ref: '#/definitions/SubEntity'
actions:
type: array
items:
$ref: '#/definitions/Action'
links:
type: array
items:
$ref: '#/definitions/Link'
SubEntity:
type: object
properties:
href:
type: string
rel:
type: array
items:
type: string
class:
type: array
items:
type: string
properties:
type: object
entities:
type: array
items:
$ref: '#/definitions/SubEntity'
actions:
type: array
items:
$ref: '#/definitions/Action'
links:
type: array
items:
$ref: '#/definitions/Link'
Action:
type: object
required:
- name
- href
properties:
class:
type: array
items:
type: string
name:
type: string
method:
type: string
href:
type: string
title:
type: string
type:
type: string
fields:
type: array
items:
$ref: '#/definitions/Field'
Field:
type: object
required:
- name
properties:
name:
type: string
type:
type: string
enum:
- hidden
- text
- search
- tel
- url
- email
- password
- datetime
- date
- month
- week
- time
- datetime-local
- number
- range
- color
- checkbox
- radio
- file
title:
type: string
value:
type: string
Link:
type: object
required:
- rel
- href
properties:
class:
type: array
items:
type: string
title:
type: string
rel:
type: array
items:
type: string
href:
type: string
type:
type: string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment