Open ddorian opened 1 week ago
This PR gave me some inspiration.
I don't quite agree with PR #190's approach, self._register_default_error_responses()
only refactored part of the functionality.
You can expose self.generate_spec_json()
function on top of this PR to implement spec_json
refactoring.
self.generate_spec_json()
contains all the remaining logic
@property
def api_doc(self) -> Dict:
if self.spec_json:
return self.spec_json
+ self.spec_json = self.generate_spec_json()
+ return self.spec_json
The difference is if you want to modify the whole thing or piece by piece.
Both ways would be best IMO.
This will make it easier for APISpec to be modified by external functions before generating the spec_json (examples: adding webhooks, registering custom components etc).
Checklist:
pytest tests
and no failed.ruff check flask_openapi3 tests examples
and no failed.mypy flask_openapi3
and no failed.mkdocs serve
and no failed.