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

fix(type-safe-api): fix syntax error for python runtime request parameters with descriptions #610

Merged
merged 2 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations
import urllib.parse
import json
from typing import Callable, Any, Dict, List, NamedTuple, TypeVar, Generic, Union, TypedDict, Protocol, Optional, Literal
from typing import Callable, Any, Dict, List, NamedTuple, TypeVar, Generic, Union, TypedDict, Protocol, Optional, Literal, Annotated
cogwirrel marked this conversation as resolved.
Show resolved Hide resolved
from functools import wraps
from dataclasses import dataclass, fields
from datetime import datetime
Expand Down Expand Up @@ -215,7 +215,7 @@ class {{operationIdCamelCase}}RequestParameters(BaseModel):
"""
{{#allParams}}
{{^isBodyParam}}
{{paramName}}: {{vendorExtensions.x-py-typing}} = Field(alias='{{baseName}}'{{^required}}, default=None{{/required}})
{{paramName}}: {{{vendorExtensions.x-py-typing}}}
{{/isBodyParam}}
{{/allParams}}

Expand All @@ -232,7 +232,7 @@ class {{operationIdCamelCase}}RequestParameters(BaseModel):
return cls.from_dict(json.loads(json_str))

def to_dict(self):
return self.dict(by_alias=True, exclude={}, exclude_none=True)
return self.dict(exclude={}, exclude_none=True)

@classmethod
def from_dict(cls, obj: dict) -> {{operationIdCamelCase}}RequestParameters:
Expand Down
6 changes: 6 additions & 0 deletions packages/type-safe-api/test/resources/specs/single.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ paths:
parameters:
- in: query
name: param1
description: This is parameter 1
schema:
type: string
required: true
- in: query
name: param2
description: This is parameter 2
schema:
type: array
items:
Expand All @@ -36,6 +38,7 @@ paths:
required: true
- in: header
name: x-header-param
description: This is a header parameter
schema:
type: string
required: true
Expand Down Expand Up @@ -149,11 +152,13 @@ components:
required:
- errorMessage
TestRequest:
description: This is a test request
type: object
properties:
myInput:
type: number
TestResponse:
description: This is a test response
type: object
properties:
messages:
Expand All @@ -162,6 +167,7 @@ components:
type: object
properties:
message:
description: This is a message
type: string
id:
type: integer
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading