-
Notifications
You must be signed in to change notification settings - Fork 39
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
Unwrap the API RequestObject for the function validation if it's a nested pydantic class #68
Conversation
…sted pydantic class
Temporarily remove `| JsonResponse` type hint.
@@ -38,14 +38,21 @@ async def develop_application(ids: Identifiers, spec: Specification) -> Complete | |||
compiled_routes = [] | |||
if spec.ApiRouteSpecs: | |||
for api_route in spec.ApiRouteSpecs: | |||
if not api_route.RequestObject: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a better course of action here would be for me to separate route and query/body params and insert them separately. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we are fine for now?
@@ -1,5 +1,5 @@ | |||
from prisma.models import Specification | |||
from prisma.types import SpecificationCreateInput | |||
from prisma.models import ObjectField, ObjectType, Specification |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Swiftyos I guess this change is not needed depending on what's our plan on collecting the DataType
codex/develop/compile.py
Outdated
@@ -312,7 +305,8 @@ def create_server_route_code(complied_route: CompiledRoute) -> str: | |||
is_file_response = True | |||
else: | |||
if return_type.Type is not None: | |||
response_model = f"{return_type.Type.name} | JSONResponse" | |||
# TODO(SwiftyOS): consider revert, `| JSONResponse` was removed from here. | |||
response_model = return_type.Type.name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I needed to have 2 response models, 1 if the | json as the function return type and 1 for the route annotation.
I'll push an update for this.
route_fucntion_def += ")" | ||
|
||
# TODO(SwiftyOS): consider replacing the prefix with a proper import and func call. | ||
route_function_def = f"def api_{http_verb.lower()}_{main_function.functionName}(" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, I had this previously and forgot to add it during the rewrite.
The only additional thing I had was I was also storing a set of the route function names, if it turned up more than once I added a random string to the end.
Though that is a hack, we should add this as a validation step on the route definition creation
It's tested using
api_test.py