-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): adds response formatting to api requests
Adds response formatting to api requests in new fastapi framework closes #4636
- Loading branch information
Showing
15 changed files
with
658 additions
and
264 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,6 @@ | ||
from typing import Mapping, Union | ||
from pydantic import BaseModel | ||
|
||
class LinkHref(BaseModel): | ||
href: str | ||
meta: dict | ||
class ResourceLinks(BaseModel): | ||
self: str | ||
|
||
Link = Union[str, LinkHref] | ||
ResourceLinks = Mapping[str, Link] | ||
ResourceLinks.__doc__ = "https://jsonapi.org/format/#document-links" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from pydantic import BaseModel | ||
from opentrons.app.models.json_api.request import JsonApiRequest | ||
from dataclasses import dataclass | ||
from uuid import uuid4 | ||
|
||
@dataclass | ||
class ItemData: | ||
name: str | ||
quantity: int | ||
price: float | ||
id: str = str(uuid4().hex) | ||
|
||
class ItemModel(BaseModel): | ||
name: str | ||
quantity: int | ||
price: float | ||
|
||
item_type_name = 'item' | ||
ItemRequest = JsonApiRequest(item_type_name, ItemModel) |
Oops, something went wrong.