17
17
APIRequest ,
18
18
CollectionUri ,
19
19
EmptyRequest ,
20
+ GeoJSONResponse ,
20
21
ItemCollectionUri ,
21
22
ItemUri ,
22
23
SearchGetRequest ,
@@ -96,17 +97,16 @@ def get_extension(self, extension: Type[ApiExtension]) -> Optional[ApiExtension]
96
97
return None
97
98
98
99
def _create_endpoint (
99
- self , func : Callable , request_type : Union [Type [APIRequest ], Type [BaseModel ]]
100
+ self ,
101
+ func : Callable ,
102
+ request_type : Union [Type [APIRequest ], Type [BaseModel ]],
103
+ resp_class : Type [Response ],
100
104
) -> Callable :
101
105
"""Create a FastAPI endpoint."""
102
106
if isinstance (self .client , AsyncBaseCoreClient ):
103
- return create_async_endpoint (
104
- func , request_type , response_class = self .response_class
105
- )
107
+ return create_async_endpoint (func , request_type , response_class = resp_class )
106
108
elif isinstance (self .client , BaseCoreClient ):
107
- return create_sync_endpoint (
108
- func , request_type , response_class = self .response_class
109
- )
109
+ return create_sync_endpoint (func , request_type , response_class = resp_class )
110
110
raise NotImplementedError
111
111
112
112
def register_landing_page (self ):
@@ -125,7 +125,9 @@ def register_landing_page(self):
125
125
response_model_exclude_unset = False ,
126
126
response_model_exclude_none = True ,
127
127
methods = ["GET" ],
128
- endpoint = self ._create_endpoint (self .client .landing_page , EmptyRequest ),
128
+ endpoint = self ._create_endpoint (
129
+ self .client .landing_page , EmptyRequest , self .response_class
130
+ ),
129
131
)
130
132
131
133
def register_conformance_classes (self ):
@@ -144,7 +146,9 @@ def register_conformance_classes(self):
144
146
response_model_exclude_unset = True ,
145
147
response_model_exclude_none = True ,
146
148
methods = ["GET" ],
147
- endpoint = self ._create_endpoint (self .client .conformance , EmptyRequest ),
149
+ endpoint = self ._create_endpoint (
150
+ self .client .conformance , EmptyRequest , self .response_class
151
+ ),
148
152
)
149
153
150
154
def register_get_item (self ):
@@ -161,7 +165,9 @@ def register_get_item(self):
161
165
response_model_exclude_unset = True ,
162
166
response_model_exclude_none = True ,
163
167
methods = ["GET" ],
164
- endpoint = self ._create_endpoint (self .client .get_item , ItemUri ),
168
+ endpoint = self ._create_endpoint (
169
+ self .client .get_item , ItemUri , self .response_class
170
+ ),
165
171
)
166
172
167
173
def register_post_search (self ):
@@ -178,12 +184,12 @@ def register_post_search(self):
178
184
response_model = (ItemCollection if not fields_ext else None )
179
185
if self .settings .enable_response_models
180
186
else None ,
181
- response_class = self . response_class ,
187
+ response_class = GeoJSONResponse ,
182
188
response_model_exclude_unset = True ,
183
189
response_model_exclude_none = True ,
184
190
methods = ["POST" ],
185
191
endpoint = self ._create_endpoint (
186
- self .client .post_search , search_request_model
192
+ self .client .post_search , search_request_model , GeoJSONResponse
187
193
),
188
194
)
189
195
@@ -200,12 +206,12 @@ def register_get_search(self):
200
206
response_model = (ItemCollection if not fields_ext else None )
201
207
if self .settings .enable_response_models
202
208
else None ,
203
- response_class = self . response_class ,
209
+ response_class = GeoJSONResponse ,
204
210
response_model_exclude_unset = True ,
205
211
response_model_exclude_none = True ,
206
212
methods = ["GET" ],
207
213
endpoint = self ._create_endpoint (
208
- self .client .get_search , self .search_get_request
214
+ self .client .get_search , self .search_get_request , GeoJSONResponse
209
215
),
210
216
)
211
217
@@ -225,7 +231,9 @@ def register_get_collections(self):
225
231
response_model_exclude_unset = True ,
226
232
response_model_exclude_none = True ,
227
233
methods = ["GET" ],
228
- endpoint = self ._create_endpoint (self .client .all_collections , EmptyRequest ),
234
+ endpoint = self ._create_endpoint (
235
+ self .client .all_collections , EmptyRequest , self .response_class
236
+ ),
229
237
)
230
238
231
239
def register_get_collection (self ):
@@ -242,7 +250,9 @@ def register_get_collection(self):
242
250
response_model_exclude_unset = True ,
243
251
response_model_exclude_none = True ,
244
252
methods = ["GET" ],
245
- endpoint = self ._create_endpoint (self .client .get_collection , CollectionUri ),
253
+ endpoint = self ._create_endpoint (
254
+ self .client .get_collection , CollectionUri , self .response_class
255
+ ),
246
256
)
247
257
248
258
def register_get_item_collection (self ):
@@ -262,7 +272,9 @@ def register_get_item_collection(self):
262
272
response_model_exclude_none = True ,
263
273
methods = ["GET" ],
264
274
endpoint = self ._create_endpoint (
265
- self .client .item_collection , self .item_collection_uri
275
+ self .client .item_collection ,
276
+ self .item_collection_uri ,
277
+ self .response_class ,
266
278
),
267
279
)
268
280
0 commit comments