Skip to content

Commit

Permalink
Remove all usage of Set in models
Browse files Browse the repository at this point in the history
  • Loading branch information
CasperWA committed Feb 27, 2020
1 parent 537d032 commit 5844765
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 36 deletions.
14 changes: 4 additions & 10 deletions openapi/index_openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,8 @@
},
"description": "A JSON object containing information about an available API version"
},
"BaseRealationshipMeta": {
"title": "BaseRealationshipMeta",
"BaseRelationshipMeta": {
"title": "BaseRelationshipMeta",
"required": [
"description"
],
Expand Down Expand Up @@ -299,7 +299,7 @@
"title": "Meta",
"allOf": [
{
"$ref": "#/components/schemas/BaseRealationshipMeta"
"$ref": "#/components/schemas/BaseRelationshipMeta"
}
],
"description": "Relationship meta field. MUST contain 'description' if supplied."
Expand Down Expand Up @@ -517,8 +517,7 @@
"type": "array",
"items": {
"$ref": "#/components/schemas/Resource"
},
"uniqueItems": true
}
}
],
"description": "Outputted Data"
Expand All @@ -528,7 +527,6 @@
},
"errors": {
"title": "Errors",
"uniqueItems": true,
"type": "array",
"items": {
"$ref": "#/components/schemas/OptimadeError"
Expand All @@ -537,7 +535,6 @@
},
"included": {
"title": "Included",
"uniqueItems": true,
"type": "array",
"items": {
"$ref": "#/components/schemas/Resource"
Expand Down Expand Up @@ -769,7 +766,6 @@
},
"errors": {
"title": "Errors",
"uniqueItems": true,
"type": "array",
"items": {
"$ref": "#/components/schemas/Error"
Expand All @@ -778,7 +774,6 @@
},
"included": {
"title": "Included",
"uniqueItems": true,
"type": "array",
"items": {
"$ref": "#/components/schemas/Resource"
Expand Down Expand Up @@ -1022,7 +1017,6 @@
},
"errors": {
"title": "Errors",
"uniqueItems": true,
"type": "array",
"items": {
"$ref": "#/components/schemas/Error"
Expand Down
20 changes: 4 additions & 16 deletions openapi/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1040,8 +1040,8 @@
},
"description": "Resource objects appear in a JSON:API document to represent resources."
},
"BaseRealationshipMeta": {
"title": "BaseRealationshipMeta",
"BaseRelationshipMeta": {
"title": "BaseRelationshipMeta",
"required": [
"description"
],
Expand Down Expand Up @@ -1077,7 +1077,7 @@
"title": "Meta",
"allOf": [
{
"$ref": "#/components/schemas/BaseRealationshipMeta"
"$ref": "#/components/schemas/BaseRelationshipMeta"
}
],
"description": "Relationship meta field. MUST contain 'description' if supplied."
Expand Down Expand Up @@ -1168,7 +1168,6 @@
},
"errors": {
"title": "Errors",
"uniqueItems": true,
"type": "array",
"items": {
"$ref": "#/components/schemas/Error"
Expand All @@ -1177,7 +1176,6 @@
},
"included": {
"title": "Included",
"uniqueItems": true,
"type": "array",
"items": {
"$ref": "#/components/schemas/Resource"
Expand Down Expand Up @@ -1415,8 +1413,7 @@
"type": "array",
"items": {
"$ref": "#/components/schemas/Resource"
},
"uniqueItems": true
}
}
],
"description": "Outputted Data"
Expand All @@ -1426,7 +1423,6 @@
},
"errors": {
"title": "Errors",
"uniqueItems": true,
"type": "array",
"items": {
"$ref": "#/components/schemas/OptimadeError"
Expand All @@ -1435,7 +1431,6 @@
},
"included": {
"title": "Included",
"uniqueItems": true,
"type": "array",
"items": {
"$ref": "#/components/schemas/Resource"
Expand Down Expand Up @@ -1558,7 +1553,6 @@
},
"errors": {
"title": "Errors",
"uniqueItems": true,
"type": "array",
"items": {
"$ref": "#/components/schemas/Error"
Expand All @@ -1567,7 +1561,6 @@
},
"included": {
"title": "Included",
"uniqueItems": true,
"type": "array",
"items": {
"$ref": "#/components/schemas/Resource"
Expand Down Expand Up @@ -1792,7 +1785,6 @@
},
"errors": {
"title": "Errors",
"uniqueItems": true,
"type": "array",
"items": {
"$ref": "#/components/schemas/Error"
Expand Down Expand Up @@ -2277,7 +2269,6 @@
},
"errors": {
"title": "Errors",
"uniqueItems": true,
"type": "array",
"items": {
"$ref": "#/components/schemas/Error"
Expand Down Expand Up @@ -2345,7 +2336,6 @@
},
"errors": {
"title": "Errors",
"uniqueItems": true,
"type": "array",
"items": {
"$ref": "#/components/schemas/Error"
Expand Down Expand Up @@ -2999,7 +2989,6 @@
},
"errors": {
"title": "Errors",
"uniqueItems": true,
"type": "array",
"items": {
"$ref": "#/components/schemas/Error"
Expand Down Expand Up @@ -3067,7 +3056,6 @@
},
"errors": {
"title": "Errors",
"uniqueItems": true,
"type": "array",
"items": {
"$ref": "#/components/schemas/Error"
Expand Down
15 changes: 10 additions & 5 deletions optimade/models/jsonapi.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
"""This module should reproduce JSON API v1.0 https://jsonapi.org/format/1.0/"""
# pylint: disable=no-self-argument
from typing import Optional, Set, Union, List
from pydantic import BaseModel, AnyUrl, Field, root_validator
from typing import Optional, Union, List
from pydantic import ( # pylint: disable=no-name-in-module
BaseModel,
AnyUrl,
Field,
root_validator,
)


__all__ = (
Expand Down Expand Up @@ -250,15 +255,15 @@ class Resource(BaseResource):
class Response(BaseModel):
"""A top-level response"""

data: Optional[Union[None, Resource, Set[Resource]]] = Field(
data: Optional[Union[None, Resource, List[Resource]]] = Field(
None, description="Outputted Data"
)
meta: Optional[Meta] = Field(
None,
description="A meta object containing non-standard information related to the Success",
)
errors: Optional[Set[Error]] = Field(None, description="A list of errors")
included: Optional[Set[Resource]] = Field(
errors: Optional[List[Error]] = Field(None, description="A list of errors")
included: Optional[List[Resource]] = Field(
None, description="A list of resources that are included"
)
links: Optional[ToplevelLinks] = Field(
Expand Down
10 changes: 5 additions & 5 deletions optimade/models/optimade_json.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Modified JSON API v1.0 for OPTiMaDe API"""
# pylint: disable=no-self-argument,no-name-in-module
from pydantic import Field, root_validator, BaseModel
from typing import Optional, Set, Union, List
from typing import Optional, Union, List

from . import jsonapi

Expand All @@ -11,7 +11,7 @@
"Failure",
"Success",
"Warnings",
"BaseRealationshipMeta",
"BaseRelationshipMeta",
"BaseRelationshipResource",
"Relationship",
)
Expand All @@ -33,7 +33,7 @@ class Failure(jsonapi.Response):
None,
description="A meta object containing non-standard information related to the Success",
)
errors: Set[OptimadeError] = Field(
errors: List[OptimadeError] = Field(
...,
description="A list of OPTiMaDe-specific JSON API error objects, where the field detail MUST be present.",
)
Expand Down Expand Up @@ -99,7 +99,7 @@ def status_must_not_be_specified(cls, values):
return values


class BaseRealationshipMeta(BaseModel):
class BaseRelationshipMeta(BaseModel):
"""Specific meta field for base relationship resource"""

description: str = Field(
Expand All @@ -110,7 +110,7 @@ class BaseRealationshipMeta(BaseModel):
class BaseRelationshipResource(jsonapi.BaseResource):
"""Minimum requirements to represent a relationship resource"""

meta: Optional[BaseRealationshipMeta] = Field(
meta: Optional[BaseRelationshipMeta] = Field(
None,
description="Relationship meta field. MUST contain 'description' if supplied.",
)
Expand Down

0 comments on commit 5844765

Please sign in to comment.