Skip to content

Commit

Permalink
Merge pull request #20 from chrisfilo/enh/swagger
Browse files Browse the repository at this point in the history
[ENH] Added Swagger UI support
  • Loading branch information
chrisgorgo authored May 31, 2017
2 parents bce8489 + 3040dd0 commit 93a66fd
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 42 deletions.
38 changes: 2 additions & 36 deletions dockereve-master/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
# dockereve


## Overview
A sample Python Eve project with Python Gunicorn

Built on:
* [Python Eve](http://python-eve.org/)
* [Python Gunicorn](http://gunicorn.org/)
Expand All @@ -14,35 +8,7 @@ Built on:
```sh
$ docker-compose build
$ docker-compose up
$ curl -H "Content-Type: application/json" -X POST -d '{"title": "Hello World"}' http://192.168.99.100:80/scenarios
$ curl -i -H "Content-Type: application/json" http://192.168.99.100:80/scenarios
$ curl -i -H "Content-Type: application/json" http://192.168.99.100:80/T1w
```

## Contribution

### Creating Issues

If you find a problem please create an
[issue in the ticket system](https://github.com/cpapazaf/dockereve/issues)
and describe what is going wrong or what you expect to happen.
If you have a full working example or a log file this is also helpful.
You should of course describe only a single issue in a single ticket and not
mixing up several different things into a single issue.

### Creating a Pull Request

Before you create a pull request it is necessary to create an issue in
the [ticket system before](https://github.com/cpapazaf/dockereve/issues)
and describe what the problem is or what kind of feature you would like
to add. Afterwards you can create an appropriate pull request.

It is required if you want to get a Pull request to be integrated into to squash your
commits into a single commit which references the issue in the commit message.

A pull request has to fulfill only a single ticket and should never create/add/fix
several issues in one, cause otherwise the history is hard to read and to understand
and makes the maintenance of the issues and pull request hard.

## License

Distributed under the Apache License 2.0 license: http://opensource.org/licenses/Apache-2.0
Swagger API documentation available at `http://localhost/docs`.
12 changes: 9 additions & 3 deletions dockereve-master/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ nginx:
volumes:
- /www/static
volumes_from:
- web
- eve
links:
- web:web
- eve:eve
- swagger_ui:swagger_ui

swagger_ui:
image: swaggerapi/swagger-ui:v3.0.12
environment:
- API_URL=http://${HOSTNAME}/docs/api

web:
eve:
restart: always
build: eve-app
expose:
Expand Down
11 changes: 10 additions & 1 deletion dockereve-master/eve-app/app.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
from eve import Eve
from eve_swagger import swagger
from settings import my_settings as ms
import os
script_dir = os.path.dirname(os.path.abspath(__file__))


app = Eve(settings=ms)
app.register_blueprint(swagger, url_prefix='/docs/api')
app.add_url_rule('/docs/api', 'eve_swagger.index')

# required. See http://swagger.io/specification/#infoObject for details.
app.config['SWAGGER_INFO'] = {
'title': 'MRIQC Web API',
'version': '0.1',
'description': 'MRI Quality Control Metrics Repository',
}

if __name__ == '__main__':
app.run(host='0.0.0.0')
Expand Down
1 change: 1 addition & 0 deletions dockereve-master/eve-app/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
gunicorn==19.3.0
eve==0.6.3
eve-swagger==0.0.7
18 changes: 16 additions & 2 deletions dockereve-master/nginx/sites-enabled/eve_project
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,23 @@ server {
listen 80;
server_name example.org;
charset utf-8;


location = /docs/api {
proxy_pass http://eve:5000/docs/api;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

location /docs/ {
proxy_pass http://swagger_ui:8080/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

location / {
proxy_pass http://web:5000;
proxy_pass http://eve:5000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
Expand Down

0 comments on commit 93a66fd

Please sign in to comment.