Skip to content

Commit

Permalink
#15: Create method to write paths
Browse files Browse the repository at this point in the history
  • Loading branch information
keiranjprice101 committed Jul 25, 2019
1 parent 5b0c8a0 commit 3687e82
Showing 1 changed file with 196 additions and 0 deletions.
196 changes: 196 additions & 0 deletions src/swagger/swagger_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,199 @@ def get_yaml_top():
- url: http://localhost:5000
paths:''')

def get_yaml_paths(self):
"""
Gets the paths for the openapi spec
:return: String containing the paths and their methods of the openapi spec
"""
base = ""
for endpoint in self.endpoints:
base += f'''
/{endpoint.lower()}:
get:
summary: Get {SwaggerGenerator.pascal_to_normal(endpoint).lower()}
tags:
- Entities
parameters:
- name: where
in: query
description: Apply a where filter to the {SwaggerGenerator.pascal_to_normal(endpoint).lower()}
required: false
schema:
type: object
- name: limit
in: query
description: Limit the number of {SwaggerGenerator.pascal_to_normal(endpoint).lower()} returned
required: false
schema:
type: object
- name: skip
in: query
description: Skip the number of {SwaggerGenerator.pascal_to_normal(endpoint).lower()} returned
required: false
schema:
type: object
- name: order
in: query
description: order the {SwaggerGenerator.pascal_to_normal(endpoint).lower()} by the given field
required: false
schema:
type: object
- name: include
in: query
description: include the related entities given
required: false
schema:
type: object
responses:
'200':
description: The {SwaggerGenerator.pascal_to_normal(endpoint).lower()} found.
'404':
description: When no result is found
post:
summary: Create one of more {SwaggerGenerator.pascal_to_normal(endpoint).lower()}
tags:
- Entities
responses:
'200':
description: The created {SwaggerGenerator.pascal_to_normal(endpoint).lower()}
patch:
summary: Update one or multiple {SwaggerGenerator.pascal_to_normal(endpoint).lower()}
tags:
- Entities
responses:
200:
description: The updated {SwaggerGenerator.pascal_to_normal(endpoint).lower()}
/{endpoint.lower()}/count:
get:
summary: Return the count of the {SwaggerGenerator.pascal_to_normal(endpoint).lower()}
tags:
- Entities
parameters:
- name: where
in: query
description: Apply a where filter to the {SwaggerGenerator.pascal_to_normal(endpoint).lower()}
required: false
schema:
type: object
- name: limit
in: query
description: Limit the number of {SwaggerGenerator.pascal_to_normal(endpoint).lower()} returned
required: false
schema:
type: object
- name: skip
in: query
description: Skip the number of {SwaggerGenerator.pascal_to_normal(endpoint).lower()} returned
required: false
schema:
type: object
- name: order
in: query
description: order the {SwaggerGenerator.pascal_to_normal(endpoint).lower()} by the given field
required: false
schema:
type: object
- name: include
in: query
description: include the related entities given
required: false
schema:
type: object
responses:
200:
description: The count of {SwaggerGenerator.pascal_to_normal(endpoint).lower()}
/{endpoint.lower()}/findOne:
get:
summary: Return the first {SwaggerGenerator.pascal_to_normal(endpoint).lower()} matching a given filter
tags:
- Entities
parameters:
- name: where
in: query
description: Apply a where filter to the {SwaggerGenerator.pascal_to_normal(endpoint).lower()}
required: false
schema:
type: object
- name: limit
in: query
description: Limit the number of {SwaggerGenerator.pascal_to_normal(endpoint).lower()} returned
required: false
schema:
type: object
- name: skip
in: query
description: Skip the number of {SwaggerGenerator.pascal_to_normal(endpoint).lower()} returned
required: false
schema:
type: object
- name: order
in: query
description: order the {SwaggerGenerator.pascal_to_normal(endpoint).lower()} by the given field
required: false
schema:
type: object
- name: include
in: query
description: include the related entities given
required: false
schema:
type: object
responses:
200:
description: The first {SwaggerGenerator.pascal_to_normal(endpoint).lower()} matching
/{endpoint.lower()}/{{id}}:
get:
summary: Find the {SwaggerGenerator.pascal_to_normal(endpoint).lower()} matching the given ID
tags:
- Entities
parameters:
- in: path
name: id
required: true
schema:
type: integer
description: The id matching the {SwaggerGenerator.pascal_to_normal(endpoint).lower()}
responses:
'200':
description: The matching {SwaggerGenerator.pascal_to_normal(endpoint).lower()}
'404':
description: When no {SwaggerGenerator.pascal_to_normal(endpoint).lower()} matches the given ID
delete:
summary: Delete the {SwaggerGenerator.pascal_to_normal(endpoint).lower()} matching the given ID
tags:
- Entities
parameters:
- in: path
name: id
required: true
schema:
type: integer
description: The id matching the {SwaggerGenerator.pascal_to_normal(endpoint).lower()}
responses:
'203':
description: Blank responses, when the {SwaggerGenerator.pascal_to_normal(endpoint).lower()} is deleted
'404':
description: When the {SwaggerGenerator.pascal_to_normal(endpoint).lower()} can't be found
patch:
summary: Update the {SwaggerGenerator.pascal_to_normal(endpoint).lower()} matching the given ID
tags:
- Entities
parameters:
- in: path
name: id
required: true
schema:
type: integer
description: The id matching the {SwaggerGenerator.pascal_to_normal(endpoint).lower()}
responses:
'200':
description: The updated {SwaggerGenerator.pascal_to_normal(endpoint).lower()}
'404':
description: When the {SwaggerGenerator.pascal_to_normal(endpoint).lower()} can't be found'''
return base


swagger_gen = SwaggerGenerator()

0 comments on commit 3687e82

Please sign in to comment.