changes in service
This commit is contained in:
@ -11,6 +11,9 @@ HEROES = [
|
||||
]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def get_heroes():
|
||||
if HEROES:
|
||||
return HEROES
|
||||
@ -27,6 +30,9 @@ def get_hero(id=None):
|
||||
def put_hero(id=None, hero=None):
|
||||
try:
|
||||
heroToUpdate = next(x for x in HEROES if x["id"] == id)
|
||||
checkNewName = next((x for x in HEROES if x["name"] == hero["name"]), None)
|
||||
if (checkNewName):
|
||||
return 'Duplicate name', 403
|
||||
heroToUpdate["name"] = hero["name"]
|
||||
return 'Hero updated', 200
|
||||
except StopIteration:
|
||||
|
@ -1,7 +1,7 @@
|
||||
[uwsgi]
|
||||
http = :5000
|
||||
wsgi-file = server.py
|
||||
processes = 4
|
||||
threads = 2
|
||||
processes = 1
|
||||
threads = 1
|
||||
stats = 127.0.0.1:9191
|
||||
|
||||
|
100
tools/ws/swagger.yaml
Normal file
100
tools/ws/swagger.yaml
Normal file
@ -0,0 +1,100 @@
|
||||
swagger: '2.0'
|
||||
info:
|
||||
title: Hello API
|
||||
version: "0.1"
|
||||
|
||||
paths:
|
||||
/greeting:
|
||||
get:
|
||||
operationId: api.say_hello
|
||||
summary: Returns a greeting
|
||||
parameters:
|
||||
- name: name
|
||||
in: query
|
||||
type: string
|
||||
responses:
|
||||
200:
|
||||
description: Successful response.
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
message:
|
||||
type: string
|
||||
description: Message greeting
|
||||
/hero/{id}:
|
||||
get:
|
||||
operationId: heroes.get_hero
|
||||
summary: Returns hero by id
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
type: integer
|
||||
required: true
|
||||
responses:
|
||||
200:
|
||||
description: Successful response.
|
||||
schema:
|
||||
$ref: '#/definitions/Hero'
|
||||
404:
|
||||
description: Hero not found
|
||||
put:
|
||||
operationId: heroes.put_hero
|
||||
summary: Update a hero
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
type: integer
|
||||
required: true
|
||||
- name: hero
|
||||
in: body
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/Hero'
|
||||
responses:
|
||||
200:
|
||||
description: Hero updated
|
||||
402:
|
||||
description: Duplicate name
|
||||
403:
|
||||
description: Some error
|
||||
404:
|
||||
description: Hero not found
|
||||
/hero:
|
||||
post:
|
||||
operationId: heroes.post_hero
|
||||
summary: Insert a hero
|
||||
parameters:
|
||||
- name: hero
|
||||
in: body
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/Hero'
|
||||
responses:
|
||||
200:
|
||||
description: Hero inserted
|
||||
403:
|
||||
description: Some error
|
||||
/heroes:
|
||||
get:
|
||||
operationId: heroes.get_heroes
|
||||
summary: Returns all heroes
|
||||
responses:
|
||||
200:
|
||||
description: Successful response.
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/definitions/Hero'
|
||||
404:
|
||||
description: No heroes available
|
||||
|
||||
|
||||
definitions:
|
||||
Hero:
|
||||
description: Hero type
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
name:
|
||||
type: string
|
Reference in New Issue
Block a user