-
Notifications
You must be signed in to change notification settings - Fork 40
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
Seperated Links from JSON API into its own file #30
Changes from 2 commits
1428c39
fc4fee9
8840007
d96d425
8ba0b25
20da9f4
ee64b08
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from optimade.server.models.jsonapi import Link, Links, Source | ||
|
||
from datetime import datetime | ||
from pydantic import UrlStr, BaseModel | ||
from typing import Optional, Union, Any | ||
|
||
class Attributes(BaseModel): | ||
local_id: UrlStr | ||
lad_modified: datetime | ||
immutable_id: Optional[UrlStr] | ||
|
||
class ErrorLinks(BaseModel): | ||
about: Union[Link, UrlStr] | ||
|
||
class Error(BaseModel): | ||
id: Optional[str] | ||
status: Optional[str] | ||
code: Optional[str] | ||
title: Optional[str] | ||
detail: Optional[str] | ||
source: Optional[Source] | ||
meta: Optional[dict] | ||
links: Optional[ErrorLinks] | ||
|
||
class Links(Links): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I find this very ugly, redefinition of the same name when importing something? Looks like a problem waiting to happen There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you could simply There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My preference here would be to just import the namespace and then use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. even better! |
||
base_rul: Optional[Union[Link, UrlStr]] |
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.
Just a question: is it necessary to escape quotation marks here?
Does it otherwise break the JSON?
I would have thought pydantic could be a bit more clever...