Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(event_handler): add bedrock agent resolver documentation #3602

Merged
merged 54 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
c729d29
chore(docs): add bedrock agent resolver documentation
rubenfonseca Jan 8, 2024
f54a585
Merge branch 'develop' into rf/bedrock-agents-docs
leandrodamascena Jan 9, 2024
28958b1
chore: refactor documentation
rubenfonseca Feb 9, 2024
7910196
Merge branch 'develop' into rf/bedrock-agents-docs
rubenfonseca Feb 9, 2024
f36d174
Merge branch 'develop' into rf/bedrock-agents-docs
rubenfonseca Feb 9, 2024
9fce88b
chore: fix mistakes
rubenfonseca Feb 9, 2024
476aed1
chore: fix more mistakes
rubenfonseca Feb 9, 2024
561371d
fix: some notes
rubenfonseca Feb 13, 2024
ebc47db
chore: trademarks
rubenfonseca Feb 15, 2024
6f1350b
chore: add sam
rubenfonseca Feb 15, 2024
a3ecb8c
fix: input/output
rubenfonseca Feb 15, 2024
cc72a3e
chore: default description
rubenfonseca Feb 15, 2024
c42ee6d
fix: mypy
rubenfonseca Feb 16, 2024
e7017cb
fix: referenecs
rubenfonseca Feb 16, 2024
221e025
chore: add data validation example
rubenfonseca Feb 16, 2024
cbcaf3b
fix: typing import
rubenfonseca Feb 16, 2024
d9ff550
fix: typing
rubenfonseca Feb 16, 2024
2ece75c
chore: add video
rubenfonseca Feb 16, 2024
8352778
chore: add example of customizing parameters
rubenfonseca Feb 16, 2024
5ebdc3a
chore: add diagram
rubenfonseca Feb 19, 2024
ca76fd3
chore(deps): feedback part 1
rubenfonseca Feb 26, 2024
62f5316
Merge branch 'develop' into rf/bedrock-agents-docs
rubenfonseca Feb 27, 2024
8b5b792
chore: xxx
rubenfonseca Feb 27, 2024
695cf8d
chore: make description required
rubenfonseca Feb 27, 2024
c485de0
chore: remove the magic
rubenfonseca Feb 27, 2024
3dec9ab
chore: re-add magic comment
rubenfonseca Feb 27, 2024
1438a12
chore: add missing dependencies
rubenfonseca Feb 27, 2024
251c939
chore: add ugly note about pydantic v1
rubenfonseca Feb 27, 2024
91de6b1
chore: more feedback
rubenfonseca Feb 27, 2024
1268937
chore: added Alex's comments
rubenfonseca Feb 27, 2024
a9c56a3
chore: adding second option for intro overview
rubenfonseca Feb 27, 2024
cd89d47
chore: add agents definition
rubenfonseca Feb 27, 2024
59b3037
Merge branch 'develop' into rf/bedrock-agents-docs
rubenfonseca Feb 27, 2024
6430262
fix: types
rubenfonseca Feb 27, 2024
631ad7a
chore: addressed feedback
rubenfonseca Feb 28, 2024
0789da1
chore: addressed permissions feedback
rubenfonseca Feb 28, 2024
9864188
chore: expanded pydantic explanation
rubenfonseca Feb 28, 2024
b29112c
chore: add sentence on regenerating openapi schemas
rubenfonseca Feb 28, 2024
ada255c
chore: color contrast
rubenfonseca Feb 28, 2024
59411ad
chore: improved input validation
rubenfonseca Feb 29, 2024
9542989
chore: sample of additional properties
rubenfonseca Feb 29, 2024
4a765fb
chore: add more diagrams
rubenfonseca Feb 29, 2024
cad892d
Merge branch 'develop' into rf/bedrock-agents-docs
rubenfonseca Feb 29, 2024
afe8fe0
fix: applied feedback
rubenfonseca Mar 1, 2024
d16448d
Merge branch 'develop' into rf/bedrock-agents-docs
rubenfonseca Mar 1, 2024
0d19c1e
chore: apply upstream changes
rubenfonseca Mar 5, 2024
20c3ce1
Merge branch 'develop' into rf/bedrock-agents-docs
rubenfonseca Mar 5, 2024
0da3057
fix: weird characters
rubenfonseca Mar 5, 2024
81945df
fix: wording
rubenfonseca Mar 5, 2024
8e848fe
fix: wording
rubenfonseca Mar 5, 2024
9e5b052
fix: make all schemas 3.0.3
rubenfonseca Mar 5, 2024
59ea627
fix: highlight
rubenfonseca Mar 5, 2024
1efcad8
fix: fix
rubenfonseca Mar 5, 2024
a9d3a63
fix: fix
rubenfonseca Mar 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/core/event_handler/_openapi_customization_intro.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!-- markdownlint-disable MD041 MD043 -->
In OpenAPI documentation tools like [SwaggerUI](api-gateway.md#enabling-swaggerui), these annotations become readable descriptions, offering a self-explanatory API interface. This reduces boilerplate code while improving functionality and enabling auto-documentation.

???+ note
We don't have support for files, form data, and header parameters at the moment. If you're interested in this, please [open an issue](https://github.com/aws-powertools/powertools-lambda-python/issues/new?assignees=&labels=feature-request%2Ctriage&projects=&template=feature_request.yml&title=Feature+request%3A+TITLE).
15 changes: 15 additions & 0 deletions docs/core/event_handler/_openapi_customization_metadata.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!-- markdownlint-disable MD041 MD043 -->
Defining and customizing OpenAPI metadata gives detailed, top-level information about your API. Here's the method to set and tailor this metadata:

| Field Name | Type | Description |
| ------------------ | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `title` | `str` | The title for your API. It should be a concise, specific name that can be used to identify the API in documentation or listings. |
| `version` | `str` | The version of the API you are documenting. This could reflect the release iteration of the API and helps clients understand the evolution of the API. |
| `openapi_version` | `str` | Specifies the version of the OpenAPI Specification on which your API is based. For most contemporary APIs, the default value would be `3.0.0` or higher. |
| `summary` | `str` | A short and informative summary that can provide an overview of what the API does. This can be the same as or different from the title but should add context or information. |
| `description` | `str` | A verbose description that can include Markdown formatting, providing a full explanation of the API's purpose, functionalities, and general usage instructions. |
| `tags` | `List[str]` | A collection of tags that categorize endpoints for better organization and navigation within the documentation. This can group endpoints by their functionality or other criteria. |
| `servers` | `List[Server]` | An array of Server objects, which specify the URL to the server and a description for its environment (production, staging, development, etc.), providing connectivity information. |
| `terms_of_service` | `str` | A URL that points to the terms of service for your API. This could provide legal information and user responsibilities related to the usage of the API. |
| `contact` | `Contact` | A Contact object containing contact details of the organization or individuals maintaining the API. This may include fields such as name, URL, and email. |
| `license_info` | `License` | A License object providing the license details for the API, typically including the name of the license and the URL to the full license text. |
14 changes: 14 additions & 0 deletions docs/core/event_handler/_openapi_customization_operations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!-- markdownlint-disable MD041 MD043 -->
Customize your API endpoints by adding metadata to endpoint definitions. This provides descriptive documentation for API consumers and gives extra instructions to the framework.

Here's a breakdown of various customizable fields:

| Field Name | Type | Description |
| ---------------------- | --------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `summary` | `str` | A concise overview of the main functionality of the endpoint. This brief introduction is usually displayed in autogenerated API documentation and helps consumers quickly understand what the endpoint does. |
| `description` | `str` | A more detailed explanation of the endpoint, which can include information about the operation's behavior, including side effects, error states, and other operational guidelines. |
| `responses` | `Dict[int, Dict[str, Any]]` | A dictionary that maps each HTTP status code to a Response Object as defined by the [OpenAPI Specification](https://swagger.io/specification/#response-object). This allows you to describe expected responses, including default or error messages, and their corresponding schemas for different status codes. |
| `response_description` | `str` | Provides the default textual description of the response sent by the endpoint when the operation is successful. It is intended to give a human-readable understanding of the result. |
| `tags` | `List[str]` | Tags are a way to categorize and group endpoints within the API documentation. They can help organize the operations by resources or other heuristic. |
| `operation_id` | `str` | A unique identifier for the operation, which can be used for referencing this operation in documentation or code. This ID must be unique across all operations described in the API. |
| `include_in_schema` | `bool` | A boolean value that determines whether or not this operation should be included in the OpenAPI schema. Setting it to `False` can hide the endpoint from generated documentation and schema exports, which might be useful for private or experimental endpoints. |
25 changes: 25 additions & 0 deletions docs/core/event_handler/_openapi_customization_parameters.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!-- markdownlint-disable MD041 MD043 -->
Whenever you use OpenAPI parameters to validate [query strings](api_gateway.md#validating-query-strings) or [path parameters](api_gateway.md#validating-path-parameters), you can enhance validation and OpenAPI documentation by using any of these parameters:

| Field name | Type | Description |
| --------------------- | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `alias` | `str` | Alternative name for a field, used when serializing and deserializing data |
| `validation_alias` | `str` | Alternative name for a field during validation (but not serialization) |
| `serialization_alias` | `str` | Alternative name for a field during serialization (but not during validation) |
| `description` | `str` | Human-readable description |
| `gt` | `float` | Greater than. If set, value must be greater than this. Only applicable to numbers |
| `ge` | `float` | Greater than or equal. If set, value must be greater than or equal to this. Only applicable to numbers |
| `lt` | `float` | Less than. If set, value must be less than this. Only applicable to numbers |
| `le` | `float` | Less than or equal. If set, value must be less than or equal to this. Only applicable to numbers |
| `min_length` | `int` | Minimum length for strings |
| `max_length` | `int` | Maximum length for strings |
| `pattern` | `string` | A regular expression that the string must match. |
| `strict` | `bool` | If `True`, strict validation is applied to the field. See [Strict Mode](https://docs.pydantic.dev/latest/concepts/strict_mode/){target"_blank" rel="nofollow"} for details |
| `multiple_of` | `float` | Value must be a multiple of this. Only applicable to numbers |
| `allow_inf_nan` | `bool` | Allow `inf`, `-inf`, `nan`. Only applicable to numbers |
| `max_digits` | `int` | Maximum number of allow digits for strings |
| `decimal_places` | `int` | Maximum number of decimal places allowed for numbers |
| `examples` | `List\[Any\]` | List of examples of the field |
| `deprecated` | `bool` | Marks the field as deprecated |
| `include_in_schema` | `bool` | If `False` the field will not be part of the exported OpenAPI schema |
| `json_schema_extra` | `JsonDict` | Any additional JSON schema data for the schema property |
5 changes: 5 additions & 0 deletions docs/core/event_handler/_openapi_customization_swagger.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!-- markdownlint-disable MD041 MD043 -->
???+note "Customizing the Swagger metadata"
The `enable_swagger` method accepts the same metadata as described at [Customizing OpenAPI metadata](api_gateway.md#customizing-openapi-metadata).

The Swagger UI appears by default at the `/swagger` path, but you can customize this to serve the documentation from another path and specify the source for Swagger UI assets.
10 changes: 10 additions & 0 deletions docs/core/event_handler/_swagger_ui.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!-- markdownlint-disable MD041 MD043 -->
Behind the scenes, the [data validation](api_gateway.md#data-validation) feature auto-generates an OpenAPI specification from your routes and type annotations. You can use [Swagger UI](https://swagger.io/tools/swagger-ui/){target="_blank" rel="nofollow"} to visualize and interact with your newly auto-documented API.

There are some important **caveats** that you should know before enabling it:

| Caveat | Description |
| ------------------------------------------------ |--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Swagger UI is **publicly accessible by default** | When using `enable_swagger` method, you can [protect sensitive API endpoints by implementing a custom middleware](api_gateway.md#customizing-swagger-ui) using your preferred authorization mechanism. |
| **No micro-functions support** yet | Swagger UI is enabled on a per resolver instance which will limit its accuracy here. |
| You need to expose **new routes** | You'll need to expose the following paths to Lambda: `/swagger`, `/swagger.css`, `/swagger.js`; ignore if you're routing all paths already. |