Skip to content

Commit 449afe4

Browse files
authored
fix(api): register responses with apispec using components.response() (#1881)
responses should be registered with apispec using components.response(); not by directly modifying the _reponses dict, which is internal to the ApiSpec.Components class. Also, handle duplicate response registrations gracefully.
1 parent 71e7847 commit 449afe4

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

flask_appbuilder/api/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,10 @@ def add_api_spec(self, api_spec: APISpec) -> None:
533533

534534
def add_apispec_components(self, api_spec: APISpec) -> None:
535535
for k, v in self.responses.items():
536-
api_spec.components._responses[k] = v
536+
try:
537+
api_spec.components.response(k, v)
538+
except DuplicateComponentNameError:
539+
pass
537540
for k, v in self._apispec_parameter_schemas.items():
538541
try:
539542
api_spec.components.schema(k, v)

0 commit comments

Comments
 (0)