Comments (5)
found this:
sanic-ext/sanic_ext/extensions/openapi/builders.py
Lines 137 to 149 in 4a6dda9
the _build_merged_dict
function can merge three dicts which names are default_dict
, autodoc_dict
and defined_dict
into one, but when the key is 'parameters' for example, it will just cover the autodoc_dict
's value by the defined_dict
's value and not merge these values.
from sanic-ext.
@nightstream Thanks for debugging this! You are right, swapping the order fixes the problem.
@app.get("/<pk:strorempty>")
async def handler(request: Request, pk: Optional[str]):
"""
openapi:
---
parameters:
- pk:
name: pk
in: path
required: false
schema:
type: string
"""
return json({"foo": pk})
With this line in place, it works as expected
for d in (default_dict, defined_dict, autodoc_dict):
Will get this in the next bug release coming soon.
from sanic-ext.
There is probably a bigger issue that needs to be addressed in that Optional[str]
should auto-imply strorempty
, which should mark it as required=false
automatically. But a simple fix for now is the order.
from sanic-ext.
So, upon further thought, this one might need a little more consideration. Because there are certain things that we DO want defined_dict
to take precedence. Primarily when you do not intend for docstring to be included and want to override the description or summary.
I think we either need another hierarchy to split apart decorators and route definitions, or carve an exception into the priority ordering for this use case.
from sanic-ext.
Just pushed another change to that PR. This should do the trick and not mess up the existing preferences.
from sanic-ext.
Related Issues (20)
- [Question] OpenAPI spec available on all subdomains, and route exclusion without decorators does not seem to work.
- [Bug] Dependeny Injection throw exceptions by default if @classmethod constructors don't return value/objects
- [Feature Request]
- [Bug] OpenAPI definition does not include placeholder for "headers"
- [Bug] Json validator throws 500 instead of 400
- [Feature Request] Response Compression
- [Bug] Can't use `pydantic>=2.0` model in OpenAPI definition HOT 1
- [Bug] Can't document/exclude websocket routes with OpenAPI decorator
- [Bug] Subheader "parameter" missing in sanic extensions document
- [Bug] Can't apply openapi decorators to blueprintss' routes
- [Bug]TypeError: listener() got an unexpected keyword argument 'priority' HOT 1
- [Bug] Documentation: dead link to the setting
- Query params validation is completely broken HOT 2
- Question regarding licensing info
- [Bug] Doubly defined objects in the output specification #260 HOT 2
- [Bug] The tags in OpenAPI yaml are not effective
- [Bug] Pydantic query validation with extra data not defined in model raise's KeyError
- add project to nix packages
- Add support for scalar.com OpenAPI documentation
- [Bug] Sanic validation extension failed to validate aliased pydantic model field
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sanic-ext.