Skip to content

Commit

Permalink
#87:Add swagger generation
Browse files Browse the repository at this point in the history
  • Loading branch information
keiranjprice101 committed Oct 15, 2019
1 parent 2763929 commit 58faa46
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ This is illustrated below.
│ │ └── non_entities
│ │ └── <non_entity>_endpoints.py
│ ├── swagger
│ │ └── openapi.yaml
│ │ ├── openapi.yaml
│ │ └── swagger_generator.py
│ └── main.py
├── test
│ ├── resources
Expand Down Expand Up @@ -132,6 +133,23 @@ be changed by using the arg flags `-s` or `--seed` for the seed, and `-y` or `--
For example:
`python -m util.icat_db_generator -s 4 -y 10` Would set the seed to 4 and generate 10 years of data.

#### Generating the swagger spec: `openapi.yaml`
The swagger generation script is located in `/src/swagger/swagger_generator.py`. The script will only run when
the config option `generate_swagger` is set to true in `config.json`. The generator decorates the first endpoint
resource class in it's module to get the name of the entity. It then creates the correct paths using the name of the
entity and outputs the swagger spec to `openapi.yaml`

Example of the decorator:
```python
@swagger_gen.resource_wrapper()
class DataCollectionDatasets(Resource):
@requires_session_id
@queries_records
def get(self):
return get_rows_by_filter(DATACOLLECTIONDATASET, get_filters_from_query_string()), 200
```


## Running Tests
To run the tests use `python -m unittest discover`

Expand Down

0 comments on commit 58faa46

Please sign in to comment.