Comments (6)
Hi @MCR2019 I've tried to use https://redocly.github.io/redoc/
to upload the OpenAPI generated by your code sample, and I see this.
With you change, what would be different in the UI?
from powertools-lambda-python.
Looking at this now
from powertools-lambda-python.
Hi @rubenfonseca , thanks for taking a look at that so quickly and apologies that my example wasn't as accurate as it could be.
I've had another look at it and updated the requestBody so that it uses a Pydantic schema for the type (which is what I would use to enable validation).
example code is now:
from aws_lambda_powertools.event_handler import APIGatewayRestResolver
from aws_lambda_powertools.event_handler.openapi.params import Body, Path
from aws_lambda_powertools.shared.types import Annotated
from pydantic import BaseModel, Extra, Field
app = APIGatewayRestResolver(enable_validation=True)
class ExamplePayloadSchema(BaseModel):
"""Pydantic example payload schema."""
example_attribute: str = Field(description="Warning limit for remaining IDs.", format="number")
class Config:
"""Pydantic model config."""
extra = Extra.forbid
@app.put(
"/example-resource/<path_parameter>",
)
def put(
path_parameter: Annotated[str, Path(description="test path description appears at schema and higher level", example="example01")],
event_body: Annotated[ExamplePayloadSchema, Body(description="test body description only appears at the schema level")]
):
pass
if __name__ == "__main__":
openapi_json_schema = app.get_openapi_json_schema()
with open("openapi_spec_without.json", "w") as json_spec_file:
json_spec_file.writelines(openapi_json_schema)
this produces the spec:
openapi_spec_without.json
which when an html file is generated using redoc-cli bundle -o openapi/index_without.html openapi/openapi_spec_without.json
looks like this:
(There is no description for the request body)
- Manually updating for desired output:
Manually updating the json spec file to include a description in the requestBody
(line 46):
openapi_spec_with.json
and generating html file with redoc-cli bundle -o openapi/index_with.html openapi/openapi_spec_with.json
gives an html file which shows a description for the request body:
Hopefully that illustrates the issue more clearly, I'll keep looking into what's going on and add more details if I can.
Thanks
from powertools-lambda-python.
This helps a lot! Let me see what's missing on our side.
from powertools-lambda-python.
⚠️ COMMENT VISIBILITY WARNING⚠️
This issue is now closed. Please be mindful that future comments are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.
from powertools-lambda-python.
This is now released under 2.31.0 version!
from powertools-lambda-python.
Related Issues (20)
- Maintenance: Roadmap update HOT 3
- Bug: Logs populating into cloudwatch as multiple lines instead of a single object HOT 10
- Maintenance: Update readme to style badge and remove email HOT 3
- Maintenance: Layer ARN release update is partially working HOT 4
- Bug: payload validation is skipped when item is returned via `ReturnValuesOnConditionCheckFailure` HOT 11
- Docs: remove leftover announcement banner HOT 2
- [I Made This]: reinvent session & code with Heitor HOT 3
- Docs: Fix feature flags documentation HOT 4
- Bug: Swagger generated UI has JSON format invalid URL HOT 4
- [I Made This]: Serverless API Documentation with Powertools for AWS HOT 1
- Feature request:Provide event handler for Lexv2 lambda integration HOT 1
- Bug: idempotency logic should first validate the payload and then cache HOT 2
- Bug: Event Handler Data Validation `KeyError: 'multiValueHeaders'` regression when running locally HOT 3
- Docs: Improve install section with minimal dependencies first HOT 2
- Static typing: missing @overload to ensure return type is a str when default_value is set HOT 3
- Bug: RequestValidationError handling behavior should not be affected if we add exception handler for Exception HOT 7
- Feature request: Function to retrieve mutli-value query string parameters HOT 2
- Feature request: Add event object sent from Cloudwatch Alarms HOT 7
- Bug: CORS headers not appending to API Gateway REST API responses HOT 7
- Bug: Importing AWSEncryptionSDKProvider in the AWSLambdaPowertoolsPythonV2 layer results in ModuleNotFoundError: No module named '_cffi_backend' HOT 6
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 powertools-lambda-python.