Skip to content

Commit

Permalink
fix(api): register responses with apispec using components.response() (
Browse files Browse the repository at this point in the history
…#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.
  • Loading branch information
jnahmias committed Jul 5, 2022
1 parent 71e7847 commit 449afe4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion flask_appbuilder/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,10 @@ def add_api_spec(self, api_spec: APISpec) -> None:

def add_apispec_components(self, api_spec: APISpec) -> None:
for k, v in self.responses.items():
api_spec.components._responses[k] = v
try:
api_spec.components.response(k, v)
except DuplicateComponentNameError:
pass
for k, v in self._apispec_parameter_schemas.items():
try:
api_spec.components.schema(k, v)
Expand Down

0 comments on commit 449afe4

Please sign in to comment.