Skip to content

Commit

Permalink
add responses to transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-maschler committed Apr 5, 2024
1 parent eea9c82 commit d0762eb
Showing 1 changed file with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import attr
from fastapi import APIRouter, Body, FastAPI
from stac_pydantic import Collection, Item, ItemCollection
from stac_pydantic.shared import MimeTypes
from starlette.responses import JSONResponse, Response

from stac_fastapi.api.models import CollectionUri, ItemUri
Expand Down Expand Up @@ -63,7 +64,16 @@ def register_create_item(self):
self.router.add_api_route(
name="Create Item",
path="/collections/{collection_id}/items",
status_code=201,
response_model=Item if self.settings.enable_response_models else None,
responses={
201: {
"content": {
MimeTypes.geojson.value: {},
},
"model": Item,
}
},
response_class=self.response_class,
response_model_exclude_unset=True,
response_model_exclude_none=True,
Expand All @@ -78,6 +88,14 @@ def register_update_item(self):
name="Update Item",
path="/collections/{collection_id}/items/{item_id}",
response_model=Item if self.settings.enable_response_models else None,
responses={
200: {
"content": {
MimeTypes.geojson.value: {},
},
"model": Item,
}
},
response_class=self.response_class,
response_model_exclude_unset=True,
response_model_exclude_none=True,
Expand All @@ -92,6 +110,14 @@ def register_delete_item(self):
name="Delete Item",
path="/collections/{collection_id}/items/{item_id}",
response_model=Item if self.settings.enable_response_models else None,
responses={
200: {
"content": {
MimeTypes.geojson.value: {},
},
"model": Item,
}
},
response_class=self.response_class,
response_model_exclude_unset=True,
response_model_exclude_none=True,
Expand All @@ -104,7 +130,16 @@ def register_create_collection(self):
self.router.add_api_route(
name="Create Collection",
path="/collections",
status_code=201,
response_model=Collection if self.settings.enable_response_models else None,
responses={
201: {
"content": {
MimeTypes.json.value: {},
},
"model": Collection,
}
},
response_class=self.response_class,
response_model_exclude_unset=True,
response_model_exclude_none=True,
Expand All @@ -118,6 +153,14 @@ def register_update_collection(self):
name="Update Collection",
path="/collections",
response_model=Collection if self.settings.enable_response_models else None,
responses={
200: {
"content": {
MimeTypes.json.value: {},
},
"model": Collection,
}
},
response_class=self.response_class,
response_model_exclude_unset=True,
response_model_exclude_none=True,
Expand All @@ -131,6 +174,14 @@ def register_delete_collection(self):
name="Delete Collection",
path="/collections/{collection_id}",
response_model=Collection if self.settings.enable_response_models else None,
responses={
200: {
"content": {
MimeTypes.json.value: {},
},
"model": Collection,
}
},
response_class=self.response_class,
response_model_exclude_unset=True,
response_model_exclude_none=True,
Expand Down

0 comments on commit d0762eb

Please sign in to comment.