Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
209 lines (185 sloc) 4.89 KB
# This is a swagger description of the PyMacaron Helloworld api
swagger: '2.0'
info:
title: Helloworld API
version: "0.0.1"
description: |
A few example endpoints.
host: localhost
# array of all schemes that your API supports
schemes:
- http
# will be prefixed to all paths
basePath: /v1
produces:
- application/json
paths:
/hello:
get:
summary: Say hello
description: |
Say hello. No more, no less.
tags:
- Hello
produces:
- application/json
x-bind-server: helloworld.api.do_hello
responses:
'200':
description: Hello message
schema:
$ref: '#/definitions/Hello'
/hello/with/auth:
get:
summary: Say hello but requires a valid JWT token
description: |
Say hello. Require a valid JWT token, based on the jwt_issuer,
jwt_audience and jwt_secret defined in pym-config.yaml.
tags:
- Hello
produces:
- application/json
x-bind-server: helloworld.api.do_hello
x-decorate-server: pymacaron.auth.requires_auth
responses:
'200':
description: Hello message
schema:
$ref: '#/definitions/Hello'
/hello/with/inheritance:
post:
summary: Say hello using POST and object inheritance
description: |
Say hello. This time with a POST request whose body is passed as a
pymacaron model inheriting from a custom class.
parameters:
- in: body
name: body
description: A question
required: true
schema:
$ref: "#/definitions/Question"
tags:
- Hello
produces:
- application/json
x-bind-server: helloworld.api.do_hello_with_inheritance
x-decorate-server: pymacaron.auth.requires_auth
responses:
'200':
description: Hello message
schema:
$ref: '#/definitions/Hello'
/die:
get:
summary: A failed api call
description: |
Make the server raise an exception and see how it gets handled.
tags:
- Hello
produces:
- application/json
x-bind-server: helloworld.api.do_crash
responses:
'200':
description: Hello message
schema:
$ref: '#/definitions/Hello'
/async:
get:
summary: An asynchronous api call
description: |
Start a celery task in the background and return without waiting for results.
tags:
- Hello
produces:
- application/json
x-bind-server: helloworld.api.do_async
responses:
'200':
description: Ok.
schema:
$ref: '#/definitions/Hello'
/asyncdie:
get:
summary: An asynchronous api call whose task dies
description: |
Same as /async, but the task raises an Exception. So you can watch PyMacaron's error
handler in action :-)
tags:
- Hello
produces:
- application/json
x-bind-server: helloworld.api.do_async_die
responses:
'200':
description: Ok.
schema:
$ref: '#/definitions/Hello'
definitions:
Hello:
type: object
description: Hello message
properties:
message:
type: string
description: Name of the api being served
example:
message: hello!
required:
- message
Question:
type: object
description: A question, inheriting from a custom class
x-parent: helloworld.models.Question
properties:
question:
type: string
description: A string
example:
question: anybody here?
required:
- question
Code:
type: object
description: A unique uuid4 code
properties:
code:
type: string
description: The uuid4 code
example:
code: 159f9413-a350-4b47-8442-d8308040b151
required:
- code
Error:
type: object
description: An api error
properties:
status:
type: integer
format: int32
description: HTTP error code.
error:
type: string
description: A unique identifier for this error.
error_description:
type: string
description: A humanly readable error message in the user''s selected language.
error_id:
type: string
description: Unique error id for querying error trace and analytics data
error_caught:
type: string
description: The internal error that was caught (if any)
user_message:
type: string
description: A user-friendly error message, in the user's language, to be shown in the app's alert.
required:
- status
- error
- error_description
example:
status: 500
error: SERVER_ERROR
error_description: Expected data to send in reply but got none
user_message: Something went wrong! Try again later.
You can’t perform that action at this time.