Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NOTE: DON'T MERGE (just for checking changes) #39

Open
wants to merge 84 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
3f7c64b
Added aws.py as a skeleton for upcoming AWS features
Zuiluj Apr 5, 2022
25e0158
Added skeleton tests for aws features
Zuiluj Apr 5, 2022
3619b59
Bump notebook from 6.4.8 to 6.4.10
dependabot[bot] Apr 6, 2022
5624739
Added yaml validator and have it return specific errors
Zuiluj Apr 7, 2022
ec8afcb
Made yaml validation to properly separate openapi errors and python e…
Zuiluj Apr 11, 2022
18bcf5b
Refactored default dir of swagger file. Refactored unit tests for AWS…
Zuiluj Apr 11, 2022
8bb1cd3
Finished create/update api from yaml. Added writing to config file if…
Zuiluj Apr 12, 2022
7107bbf
Reworked what exceptions does aws util react to. Added doc for aws ut…
Zuiluj Apr 13, 2022
66bd587
Merge pull request #33 from capless/dependabot/pip/notebook-6.4.10
bjinwright Apr 19, 2022
a4736c4
Did cleaning up of swaggerdoc docstrings
Zuiluj Apr 27, 2022
d9ed6ca
added generate-swagger as a cli command, creates a swagger file from …
Zuiluj May 4, 2022
4f23b85
added environment variable references for ReferenceFields and ManytoM…
bjinwright May 10, 2022
9a12433
Fixed problems associated with subclassed User and Group collections …
bjinwright May 26, 2022
a5d9a1f
updated unit tests, merging develop in
bjinwright May 27, 2022
bba4f2b
added support for splitting the docs to get params of the view
Zuiluj Jun 2, 2022
680299a
switch acquiring of swagger docs for payload from docstrings to funct…
Zuiluj Jun 2, 2022
3843493
added ability to also detect model references from _payload_docs func…
Zuiluj Jun 3, 2022
8bd2a33
Updated the docstrings of _payload_docs
Zuiluj Jun 3, 2022
74d2e64
Updated the docstrings of _payload_docs
Zuiluj Jun 3, 2022
74c0566
updated swaggyp package
Zuiluj Jun 22, 2022
9f9c818
Fixed calling of view's _payload_docs to pass the correct argument. M…
Zuiluj Jun 23, 2022
8555735
Added skeleton request for digitalocean
Zuiluj Jul 13, 2022
2e045e0
Updated digital ocean request types
Zuiluj Jul 15, 2022
4dad839
Added more properties in digital ocean request
Zuiluj Jul 15, 2022
63ed711
Refactored digitalocean request object to still try to acquire additi…
Zuiluj Jul 18, 2022
9fe3e79
Added handler for digitalocean-type requests
Zuiluj Jul 20, 2022
2ba0435
added handler for digitalocean-type requests
Zuiluj Jul 20, 2022
7b37ff5
added skeleton tests for digitalocean views
Zuiluj Jul 20, 2022
822e068
Fixed template having the wrong class name. Fixed publish function to…
Zuiluj Jul 22, 2022
7220df4
added some pep8 love and test fixes to the swagger code
bjinwright Jul 27, 2022
12028cd
updated tests
Zuiluj Jul 27, 2022
4817240
Merge pull request #37 from capless/feature/fix-auth-collections
Zuiluj Jul 27, 2022
830a5ca
Added aws.py as a skeleton for upcoming AWS features
Zuiluj Apr 5, 2022
5fbec38
Added skeleton tests for aws features
Zuiluj Apr 5, 2022
6c34dc5
Added yaml validator and have it return specific errors
Zuiluj Apr 7, 2022
0a959cb
Made yaml validation to properly separate openapi errors and python e…
Zuiluj Apr 11, 2022
882b54c
Refactored default dir of swagger file. Refactored unit tests for AWS…
Zuiluj Apr 11, 2022
eecacff
Finished create/update api from yaml. Added writing to config file if…
Zuiluj Apr 12, 2022
a4b9811
Reworked what exceptions does aws util react to. Added doc for aws ut…
Zuiluj Apr 13, 2022
4a751b6
Did cleaning up of swaggerdoc docstrings
Zuiluj Apr 27, 2022
d79a82a
added generate-swagger as a cli command, creates a swagger file from …
Zuiluj May 4, 2022
25aeaac
added support for splitting the docs to get params of the view
Zuiluj Jun 2, 2022
8d81f22
switch acquiring of swagger docs for payload from docstrings to funct…
Zuiluj Jun 2, 2022
7129fc3
added ability to also detect model references from _payload_docs func…
Zuiluj Jun 3, 2022
a007336
Updated the docstrings of _payload_docs
Zuiluj Jun 3, 2022
31dba3d
Updated the docstrings of _payload_docs
Zuiluj Jun 3, 2022
a2c4603
updated swaggyp package
Zuiluj Jun 22, 2022
3248622
Fixed calling of view's _payload_docs to pass the correct argument. M…
Zuiluj Jun 23, 2022
27cc81a
Merge branch 'feature/api_gateway_swagger' of christianllanillo:caple…
Zuiluj Jul 27, 2022
9536db1
Added aws.py as a skeleton for upcoming AWS features
Zuiluj Apr 5, 2022
9d9b0ac
Added skeleton tests for aws features
Zuiluj Apr 5, 2022
1d767ad
Added yaml validator and have it return specific errors
Zuiluj Apr 7, 2022
eb0cf78
Made yaml validation to properly separate openapi errors and python e…
Zuiluj Apr 11, 2022
0794d47
Refactored default dir of swagger file. Refactored unit tests for AWS…
Zuiluj Apr 11, 2022
d976d4e
Finished create/update api from yaml. Added writing to config file if…
Zuiluj Apr 12, 2022
b510112
Reworked what exceptions does aws util react to. Added doc for aws ut…
Zuiluj Apr 13, 2022
91e7bb3
Did cleaning up of swaggerdoc docstrings
Zuiluj Apr 27, 2022
c68975d
added generate-swagger as a cli command, creates a swagger file from …
Zuiluj May 4, 2022
40983c2
added support for splitting the docs to get params of the view
Zuiluj Jun 2, 2022
506cd85
switch acquiring of swagger docs for payload from docstrings to funct…
Zuiluj Jun 2, 2022
d30cd15
added ability to also detect model references from _payload_docs func…
Zuiluj Jun 3, 2022
8358812
Updated the docstrings of _payload_docs
Zuiluj Jun 3, 2022
3c2e122
Updated the docstrings of _payload_docs
Zuiluj Jun 3, 2022
0d0b24b
updated swaggyp package
Zuiluj Jun 22, 2022
39d50b8
Fixed calling of view's _payload_docs to pass the correct argument. M…
Zuiluj Jun 23, 2022
07d8f99
Merge branch 'feature/api_gateway_swagger' of christianllanillo:caple…
Zuiluj Jul 27, 2022
198dadc
Added yaml validator and have it return specific errors
Zuiluj Apr 7, 2022
150c916
Made yaml validation to properly separate openapi errors and python e…
Zuiluj Apr 11, 2022
4464f03
Finished create/update api from yaml. Added writing to config file if…
Zuiluj Apr 12, 2022
461e73f
added support for splitting the docs to get params of the view
Zuiluj Jun 2, 2022
5a1ae8e
switch acquiring of swagger docs for payload from docstrings to funct…
Zuiluj Jun 2, 2022
d2d054f
added ability to also detect model references from _payload_docs func…
Zuiluj Jun 3, 2022
88dd53b
updated swaggyp package
Zuiluj Jun 22, 2022
81564c5
Merge branch 'feature/api_gateway_swagger' of christianllanillo:caple…
Zuiluj Jul 27, 2022
3a27197
Added skeleton request for digitalocean
Zuiluj Jul 13, 2022
04ab858
Added more properties in digital ocean request
Zuiluj Jul 15, 2022
a468a49
Refactored digitalocean request object to still try to acquire additi…
Zuiluj Jul 18, 2022
44c786b
Added handler for digitalocean-type requests
Zuiluj Jul 20, 2022
dcace0e
added handler for digitalocean-type requests
Zuiluj Jul 20, 2022
5f5ebce
added skeleton tests for digitalocean views
Zuiluj Jul 20, 2022
dc55ba2
Fixed template having the wrong class name. Fixed publish function to…
Zuiluj Jul 22, 2022
84f1a9a
updated tests
Zuiluj Jul 27, 2022
88debff
Merge branch 'feature/digitalocean_publish' of christianllanillo:capl…
Zuiluj Jul 27, 2022
471fe88
fixed unittests
Zuiluj Jul 27, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
switch acquiring of swagger docs for payload from docstrings to funct…
…ion return instead
Zuiluj committed Jun 2, 2022
commit 680299a9cc082fe644bb2feb9897786793fdef84
20 changes: 8 additions & 12 deletions pfunk/utils/swagger.py
Original file line number Diff line number Diff line change
@@ -163,6 +163,7 @@ def get_operations(self, col: Collection):
```
"""
for view in col.collection_views:
v = view()
route = view.url(col)
rule = route.rule
methods = route.methods
@@ -211,17 +212,13 @@ def get_operations(self, col: Collection):
)
params.append(path_params)

# Acquire payload of the view from the View's docstring
# where to cut the docstrings to use the definition for the payload of the view
oas_str_split = '[OAS]\n'
view_docs = view.__doc__
view_payload = None
if (view_docs and len(view_docs.split(oas_str_split)) > 1):
view_payload = view_docs.split(oas_str_split)[1]
# Acquire payload of the view from the View's `_payload_docs`
view_payload = view()._payload_docs()

# Construct payload for swagger generation
# TODO: support referencing of models
if view_payload:
for field in json.loads(view_payload).get('data'):
for field in view_payload.get('data'):
param = sw.Parameter(
name=field.get('name'),
_type=field.get('type'),
@@ -232,17 +229,16 @@ def get_operations(self, col: Collection):
)
params.append(param)

docs_description = view_docs if not len(view_docs.split(
oas_str_split)) > 1 else view_docs.split(oas_str_split)[0]
consumes = ['application/json',
'application/x-www-form-urlencoded']
produces = ['application/json',
'application/x-www-form-urlencoded']
view_docs = view.__doc__
if params:
op = sw.Operation(
http_method=method.lower(),
summary=f'({method}) -> {col.__class__.__name__}',
description=docs_description,
description=view_docs,
responses=responses,
consumes=consumes,
produces=produces,
@@ -251,7 +247,7 @@ def get_operations(self, col: Collection):
op = sw.Operation(
http_method=method.lower(),
summary=f'({method}) -> {col.__class__.__name__}',
description=docs_description,
description=view_docs,
responses=responses,
consumes=consumes,
produces=produces)
34 changes: 30 additions & 4 deletions pfunk/web/views/json.py
Original file line number Diff line number Diff line change
@@ -25,6 +25,29 @@ def get_response(self):
headers=self.get_headers()
)

def _payload_docs(self):
""" Used in defining payload parameters for the view.
Should return a dict that has the fields of a swagger parameter e.g.
{"data": [
{
"name":"name",
"in":"formData",
"description":"name of the pet",
"required": true,
"type": "string"
},
{
"name": "status",
"in": "formData",
"description": "status of the pet",
"required":true,
"type":"string"
}
]}
"""
return {}


class CreateView(UpdateMixin, ActionMixin, JSONView):
""" Define a `Create` view that allows `creation` of an entity in the collection """
@@ -34,7 +57,8 @@ class CreateView(UpdateMixin, ActionMixin, JSONView):

def get_query(self):
""" Entity created in a collection """
obj = self.collection.create(**self.get_query_kwargs(), _token=self.request.token)
obj = self.collection.create(
**self.get_query_kwargs(), _token=self.request.token)
return obj

def get_m2m_kwargs(self, obj):
@@ -50,7 +74,8 @@ def get_m2m_kwargs(self, obj):
"""
data = self.request.get_json()
fields = self.collection.get_foreign_fields_by_type('pfunk.fields.ManyToManyField')
fields = self.collection.get_foreign_fields_by_type(
'pfunk.fields.ManyToManyField')
for k, v in fields.items():
current_value = data.get(k)
col = v.get('foreign_class')()
@@ -70,7 +95,8 @@ class UpdateView(UpdateMixin, IDMixin, JSONView):

def get_query(self):
""" Entity in collection updated by an ID """
obj = self.collection.get(self.request.kwargs.get('id'), _token=self.request.token)
obj = self.collection.get(self.request.kwargs.get(
'id'), _token=self.request.token)
obj._data.update(self.get_query_kwargs())
obj.save()
return obj
@@ -102,4 +128,4 @@ class ListView(QuerysetMixin, ActionMixin, JSONView):


class GraphQLView(HTTPView):
pass
pass