Skip to content

Commit eb25370

Browse files
authored
Merge pull request #26 from python-microservices/feature/add-swagger-conf
Extra configuration as a services
2 parents d966327 + 122eca1 commit eb25370

File tree

24 files changed

+298
-44
lines changed

24 files changed

+298
-44
lines changed

.coveragerc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ include=
33
*pyms/*
44
*tests/*
55
omit =
6-
*example/*
6+
*examples/*
77
.tox/*
88
venv/*
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from pyms.flask.app import Microservice
2+
3+
ms = Microservice(service="my-ms", path=__file__)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
pyms:
2+
requests: true
3+
swagger:
4+
path: ""
5+
file: "swagger.yaml"
6+
my-ms:
7+
DEBUG: true
8+
TESTING: false
9+
APP_NAME: "Python Microservice"
10+
APPLICATION_ROOT: ""
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from examples.microservice_requests import ms
2+
app = ms.create_app()
3+
4+
if __name__ == '__main__':
5+
app.run()
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
swagger: "2.0"
3+
info:
4+
description: "This is a sample server Test server"
5+
version: "1.0.0"
6+
title: "Swagger Test list"
7+
termsOfService: "http://swagger.io/terms/"
8+
contact:
9+
email: "apiteam@swagger.io"
10+
license:
11+
name: "Apache 2.0"
12+
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
13+
tags:
14+
- name: "colors"
15+
description: "Everything about your colors"
16+
externalDocs:
17+
description: "Find out more"
18+
url: "http://swagger.io"
19+
- name: "store"
20+
description: "Example endpoint list of colors"
21+
- name: "user"
22+
description: "Operations about user"
23+
externalDocs:
24+
description: "Find out more about our store"
25+
url: "http://swagger.io"
26+
schemes:
27+
- "http"
28+
paths:
29+
/:
30+
get:
31+
tags:
32+
- "test"
33+
summary: "Example endpoint"
34+
description: ""
35+
operationId: "examples.microservice_requests.views.example"
36+
consumes:
37+
- "application/json"
38+
produces:
39+
- "application/json"
40+
responses:
41+
200:
42+
description: "A list of colors (may be filtered by palette)"
43+
schema:
44+
$ref: '#/definitions/Example'
45+
405:
46+
description: "Invalid input"
47+
definitions:
48+
Example:
49+
type: "object"
50+
properties:
51+
main:
52+
type: "string"
53+
externalDocs:
54+
description: "Find out more about Swagger"
55+
url: "http://swagger.io"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from examples.microservice_requests import ms
2+
3+
4+
def example():
5+
return ms.requests.get_for_object("https://ghibliapi.herokuapp.com/films/2baf70d1-42bb-4437-b551-e5fed5a87abe")

examples/microservice_swagger/__init__.py

Whitespace-only changes.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
pyms:
2+
swagger:
3+
path: ""
4+
file: "swagger.yaml"
5+
my-ms:
6+
DEBUG: true
7+
TESTING: false
8+
APP_NAME: "Python Microservice"
9+
APPLICATION_ROOT: ""
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from pyms.flask.app import Microservice
2+
3+
ms = Microservice(service="my-ms", path=__file__)
4+
app = ms.create_app()
5+
6+
if __name__ == '__main__':
7+
app.run()
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
swagger: "2.0"
3+
info:
4+
description: "This is a sample server Test server"
5+
version: "1.0.0"
6+
title: "Swagger Test list"
7+
termsOfService: "http://swagger.io/terms/"
8+
contact:
9+
email: "apiteam@swagger.io"
10+
license:
11+
name: "Apache 2.0"
12+
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
13+
tags:
14+
- name: "colors"
15+
description: "Everything about your colors"
16+
externalDocs:
17+
description: "Find out more"
18+
url: "http://swagger.io"
19+
- name: "store"
20+
description: "Example endpoint list of colors"
21+
- name: "user"
22+
description: "Operations about user"
23+
externalDocs:
24+
description: "Find out more about our store"
25+
url: "http://swagger.io"
26+
schemes:
27+
- "http"
28+
paths:
29+
/:
30+
get:
31+
tags:
32+
- "test"
33+
summary: "Example endpoint"
34+
description: ""
35+
operationId: "examples.microservice_swagger.views.example"
36+
consumes:
37+
- "application/json"
38+
produces:
39+
- "application/json"
40+
responses:
41+
200:
42+
description: "A list of colors (may be filtered by palette)"
43+
schema:
44+
$ref: '#/definitions/Example'
45+
405:
46+
description: "Invalid input"
47+
definitions:
48+
Example:
49+
type: "object"
50+
properties:
51+
main:
52+
type: "string"
53+
externalDocs:
54+
description: "Find out more about Swagger"
55+
url: "http://swagger.io"

0 commit comments

Comments
 (0)