Skip to content

Commit

Permalink
Update descriptions for response models
Browse files Browse the repository at this point in the history
  • Loading branch information
CasperWA committed Feb 28, 2020
1 parent 245b66d commit f8d190f
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 19 deletions.
11 changes: 9 additions & 2 deletions openapi/index_openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,13 @@
"type": "object",
"properties": {
"data": {
"$ref": "#/components/schemas/IndexInfoResource"
"title": "Data",
"allOf": [
{
"$ref": "#/components/schemas/IndexInfoResource"
}
],
"description": "Index meta-database /info data"
},
"meta": {
"title": "Meta",
Expand Down Expand Up @@ -1028,7 +1034,8 @@
"type": "object"
}
}
]
],
"description": "List of unique OPTIMADE links resource objects"
},
"meta": {
"title": "Meta",
Expand Down
43 changes: 34 additions & 9 deletions openapi/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,13 @@
"type": "object",
"properties": {
"data": {
"$ref": "#/components/schemas/EntryInfoResource"
"title": "Data",
"allOf": [
{
"$ref": "#/components/schemas/EntryInfoResource"
}
],
"description": "OPTIMADE information for an entry endpoint"
},
"meta": {
"title": "Meta",
Expand Down Expand Up @@ -1563,7 +1569,13 @@
"type": "object",
"properties": {
"data": {
"$ref": "#/components/schemas/BaseInfoResource"
"title": "Data",
"allOf": [
{
"$ref": "#/components/schemas/BaseInfoResource"
}
],
"description": "The implementations /info data"
},
"meta": {
"title": "Meta",
Expand Down Expand Up @@ -1804,7 +1816,8 @@
"type": "object"
}
}
]
],
"description": "List of unique OPTIMADE links resource objects"
},
"meta": {
"title": "Meta",
Expand Down Expand Up @@ -2298,7 +2311,8 @@
"type": "object"
}
}
]
],
"description": "List of unique OPTIMADE references entry resource objects"
},
"meta": {
"title": "Meta",
Expand Down Expand Up @@ -2368,12 +2382,17 @@
"title": "Data",
"anyOf": [
{
"$ref": "#/components/schemas/ReferenceResource"
"allOf": [
{
"$ref": "#/components/schemas/ReferenceResource"
}
]
},
{
"type": "object"
}
]
],
"description": "A single references entry resource"
},
"meta": {
"title": "Meta",
Expand Down Expand Up @@ -3037,7 +3056,8 @@
"type": "object"
}
}
]
],
"description": "List of unique OPTIMADE structures entry resource objects"
},
"meta": {
"title": "Meta",
Expand Down Expand Up @@ -3107,12 +3127,17 @@
"title": "Data",
"anyOf": [
{
"$ref": "#/components/schemas/StructureResource"
"allOf": [
{
"$ref": "#/components/schemas/StructureResource"
}
]
},
{
"type": "object"
}
]
],
"description": "A single structures entry resource"
},
"meta": {
"title": "Meta",
Expand Down
28 changes: 20 additions & 8 deletions optimade/models/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,17 @@ def data_must_be_skipped(cls, values):


class IndexInfoResponse(Success):
data: IndexInfoResource = Field(...)
data: IndexInfoResource = Field(..., description="Index meta-database /info data")


class EntryInfoResponse(Success):
data: EntryInfoResource = Field(...)
data: EntryInfoResource = Field(
..., description="OPTIMADE information for an entry endpoint"
)


class InfoResponse(Success):
data: BaseInfoResource = Field(...)
data: BaseInfoResource = Field(..., description="The implementations /info data")


class EntryResponseOne(Success):
Expand All @@ -77,25 +79,35 @@ class EntryResponseMany(Success):

class LinksResponse(EntryResponseMany):
data: Union[List[LinksResource], List[Dict[str, Any]]] = Field(
..., uniqueItems=True
...,
description="List of unique OPTIMADE links resource objects",
uniqueItems=True,
)


class StructureResponseOne(EntryResponseOne):
data: Union[StructureResource, Dict[str, Any], None] = Field(...)
data: Union[StructureResource, Dict[str, Any], None] = Field(
..., description="A single structures entry resource"
)


class StructureResponseMany(EntryResponseMany):
data: Union[List[StructureResource], List[Dict[str, Any]]] = Field(
..., uniqueItems=True
...,
description="List of unique OPTIMADE structures entry resource objects",
uniqueItems=True,
)


class ReferenceResponseOne(EntryResponseOne):
data: Union[ReferenceResource, Dict[str, Any], None] = Field(...)
data: Union[ReferenceResource, Dict[str, Any], None] = Field(
..., description="A single references entry resource"
)


class ReferenceResponseMany(EntryResponseMany):
data: Union[List[ReferenceResource], List[Dict[str, Any]]] = Field(
..., uniqueItems=True
...,
description="List of unique OPTIMADE references entry resource objects",
uniqueItems=True,
)

0 comments on commit f8d190f

Please sign in to comment.