Change API description to a valid OpenAPI spec

* Add missing responses (doesn't include all possible responses yet)
* Refactor invalid multi in body parameters into a single parameter
* Change form type into valid formData
* Fix use of required fields
* Apply a few other minor fixes
This commit is contained in:
Sören Brunk
2019-05-28 18:04:17 +02:00
parent 844817297e
commit 30cfdcaa83

View File

@@ -1,4 +1,4 @@
# see me at: http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyterhub/master/docs/rest-api.yml#/default # see me at: http://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyterhub/jupyterhub/master/docs/rest-api.yml#/default
swagger: '2.0' swagger: '2.0'
info: info:
title: JupyterHub title: JupyterHub
@@ -7,7 +7,7 @@ info:
license: license:
name: BSD-3-Clause name: BSD-3-Clause
schemes: schemes:
- [http, https] [http, https]
securityDefinitions: securityDefinitions:
token: token:
type: apiKey type: apiKey
@@ -190,7 +190,7 @@ paths:
in: path in: path
required: true required: true
type: string type: string
- body: - name: body
in: body in: body
schema: schema:
type: object type: object
@@ -202,22 +202,21 @@ paths:
Timestamp of last-seen activity for this user. Timestamp of last-seen activity for this user.
Only needed if this is not activity associated Only needed if this is not activity associated
with using a given server. with using a given server.
required: false
servers: servers:
description: | description: |
Register activity for specific servers by name. Register activity for specific servers by name.
The keys of this dict are the names of servers. The keys of this dict are the names of servers.
The default server has an empty name (''). The default server has an empty name ('').
required: false
type: object type: object
properties: properties:
'<server name>': '<server name>':
description: | description: |
Activity for a single server. Activity for a single server.
type: object type: object
required:
- last_activity
properties: properties:
last_activity: last_activity:
required: true
type: string type: string
format: date-time format: date-time
description: | description: |
@@ -229,7 +228,11 @@ paths:
last_activity: '2019-02-06T12:54:14Z' last_activity: '2019-02-06T12:54:14Z'
gpu: gpu:
last_activity: '2019-02-06T12:54:14Z' last_activity: '2019-02-06T12:54:14Z'
responses:
'401':
$ref: '#/responses/Unauthorized'
'404':
description: No such user
/users/{name}/server: /users/{name}/server:
post: post:
summary: Start a user's single-user notebook server summary: Start a user's single-user notebook server
@@ -239,7 +242,7 @@ paths:
in: path in: path
required: true required: true
type: string type: string
- options: - name: options
description: | description: |
Spawn options can be passed as a JSON body Spawn options can be passed as a JSON body
when spawning via the API instead of spawn form. when spawning via the API instead of spawn form.
@@ -247,6 +250,7 @@ paths:
will depend on the Spawner's configuration. will depend on the Spawner's configuration.
in: body in: body
required: false required: false
schema:
type: object type: object
responses: responses:
'201': '201':
@@ -280,7 +284,7 @@ paths:
in: path in: path
required: true required: true
type: string type: string
- options: - name: options
description: | description: |
Spawn options can be passed as a JSON body Spawn options can be passed as a JSON body
when spawning via the API instead of spawn form. when spawning via the API instead of spawn form.
@@ -288,6 +292,7 @@ paths:
will depend on the Spawner's configuration. will depend on the Spawner's configuration.
in: body in: body
required: false required: false
schema:
type: object type: object
responses: responses:
'201': '201':
@@ -313,6 +318,7 @@ paths:
Removing a server deletes things like the state of the stopped server. Removing a server deletes things like the state of the stopped server.
in: body in: body
required: false required: false
schema:
type: boolean type: boolean
responses: responses:
'204': '204':
@@ -320,6 +326,12 @@ paths:
'202': '202':
description: The user's notebook named-server has not yet stopped as it is taking a while to stop description: The user's notebook named-server has not yet stopped as it is taking a while to stop
/users/{name}/tokens: /users/{name}/tokens:
parameters:
- name: name
description: username
in: path
required: true
type: string
get: get:
summary: List tokens for the user summary: List tokens for the user
responses: responses:
@@ -329,25 +341,43 @@ paths:
type: array type: array
items: items:
$ref: '#/definitions/Token' $ref: '#/definitions/Token'
'401':
$ref: '#/responses/Unauthorized'
'404':
description: No such user
post: post:
summary: Create a new token for the user summary: Create a new token for the user
parameters: parameters:
- name: expires_in - name: token_params
in: body
required: false
schema:
type: object
properties:
expires_in:
type: number type: number
required: false
in: body
description: lifetime (in seconds) after which the requested token will expire. description: lifetime (in seconds) after which the requested token will expire.
- name: note note:
type: string type: string
required: false
in: body
description: A note attached to the token for future bookkeeping description: A note attached to the token for future bookkeeping
responses: responses:
'201': '201':
description: The newly created token description: The newly created token
schema: schema:
$ref: '#/definitions/Token' $ref: '#/definitions/Token'
'400':
description: Body must be a JSON dict or empty
/users/{name}/tokens/{token_id}: /users/{name}/tokens/{token_id}:
parameters:
- name: name
description: username
in: path
required: true
type: string
- name: token_id
in: path
required: true
type: string
get: get:
summary: Get the model for a token by id summary: Get the model for a token by id
responses: responses:
@@ -361,12 +391,13 @@ paths:
'204': '204':
description: The token has been deleted description: The token has been deleted
/user: /user:
get:
summary: Return authenticated user's model summary: Return authenticated user's model
description:
parameters:
responses: responses:
'200': '200':
description: The authenticated user's model is returned. description: The authenticated user's model is returned.
schema:
$ref: '#/definitions/User'
/groups: /groups:
get: get:
summary: List groups summary: List groups
@@ -539,13 +570,14 @@ paths:
Logging in via this method is only available when the active Authenticator Logging in via this method is only available when the active Authenticator
accepts passwords (e.g. not OAuth). accepts passwords (e.g. not OAuth).
parameters: parameters:
- name: username - name: credentials
in: body in: body
required: false schema:
type: object
properties:
username:
type: string type: string
- name: password password:
in: body
required: false
type: string type: string
responses: responses:
'200': '200':
@@ -618,6 +650,11 @@ paths:
in: query in: query
required: true required: true
type: string type: string
responses:
'200':
description: Success
'400':
description: OAuth2Error
/oauth2/token: /oauth2/token:
post: post:
summary: Request an OAuth2 token summary: Request an OAuth2 token
@@ -629,27 +666,27 @@ paths:
parameters: parameters:
- name: client_id - name: client_id
description: The client id description: The client id
in: form in: formData
required: true required: true
type: string type: string
- name: client_secret - name: client_secret
description: The client secret description: The client secret
in: form in: formData
required: true required: true
type: string type: string
- name: grant_type - name: grant_type
description: The grant type (always 'authorization_code') description: The grant type (always 'authorization_code')
in: form in: formData
required: true required: true
type: string type: string
- name: code - name: code
description: The code provided by the authorization redirect description: The code provided by the authorization redirect
in: form in: formData
required: true required: true
type: string type: string
- name: redirect_uri - name: redirect_uri
description: The redirect url description: The redirect url
in: form in: formData
required: true required: true
type: string type: string
responses: responses:
@@ -668,14 +705,28 @@ paths:
post: post:
summary: Shutdown the Hub summary: Shutdown the Hub
parameters: parameters:
- name: proxy - name: body
in: body in: body
schema:
type: object
properties:
proxy:
type: boolean type: boolean
description: Whether the proxy should be shutdown as well (default from Hub config) description: Whether the proxy should be shutdown as well (default from Hub config)
- name: servers servers:
in: body
type: boolean type: boolean
description: Whether users' notebook servers should be shutdown as well (default from Hub config) description: Whether users' notebook servers should be shutdown as well (default from Hub config)
responses:
'202':
description: Shutdown successful
'400':
description: Unexpeced value for proxy or servers
# Descriptions of common responses
responses:
NotFound:
description: The specified resource was not found
Unauthorized:
description: Authentication/Authorization error
definitions: definitions:
User: User:
type: object type: object
@@ -703,10 +754,9 @@ definitions:
format: date-time format: date-time
description: Timestamp of last-seen activity from the user description: Timestamp of last-seen activity from the user
servers: servers:
type: object type: array
description: The active servers for this user. description: The active servers for this user.
items: items:
schema:
$ref: '#/definitions/Server' $ref: '#/definitions/Server'
Server: Server:
type: object type: object