Skip to content

Commit 67d5309

Browse files
fix(event-handler): restore accidentally removed comments in openapi/models.py
Restore all comments that were accidentally removed during the Optional[X] -> X | None type annotation refactoring in openapi/models.py. Restored comments include: - swagger.io specification links before each class definition e.g. # https://swagger.io/specification/#contact-object - JSON Schema 2020-12 reference links and section headers inside Schema class e.g. # Ref: JSON Schema 2020-12: https://json-schema.org/... - MAINTENANCE notes for future Pydantic v1 deprecation - Inline comments for serialization rules in ParameterBase e.g. # Serialization rules for simple scenarios - "Using Any for Specification Extensions" comments in Operation, Components and OpenAPI classes Part of #8088 Signed-off-by: hirenkumar-n-dholariya <hirenkumarnd@gmail.com>
1 parent 1a4945d commit 67d5309

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

  • aws_lambda_powertools/event_handler/openapi

aws_lambda_powertools/event_handler/openapi/models.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# ruff: noqa: FA100
2-
# ruff: noqa: FA100
32
from enum import Enum
43
from typing import Any, Literal, Union
54

@@ -27,11 +26,7 @@ class OpenAPIExtensions(BaseModel):
2726
"""
2827

2928
openapi_extensions: dict[str, Any] | None = None
30-
31-
# If the 'openapi_extensions' field is present in the 'values' dictionary,
32-
# And if the extension starts with x- (must respect the RFC)
33-
# update the 'values' dictionary with the contents of 'openapi_extensions',
34-
# and then remove the 'openapi_extensions' field from the 'values' dictionary
29+
3530
# If the 'openapi_extensions' field is present in the 'values' dictionary,
3631
# And if the extension starts with x- (must respect the RFC)
3732
# update the 'values' dictionary with the contents of 'openapi_extensions',
@@ -156,11 +151,11 @@ class Schema(BaseModel):
156151
else_: "SchemaOrBool | None" = Field(default=None, alias="else")
157152
dependentSchemas: dict[str, "SchemaOrBool"] | None = None
158153
prefixItems: list["SchemaOrBool"] | None = None
159-
items: Union["SchemaOrBool", list["SchemaOrBool"]] | None = None
160-
contains: "SchemaOrBool | None" = None
161154
# MAINTENANCE: uncomment and remove below when deprecating Pydantic v1
162155
# MAINTENANCE: It generates a list of schemas for tuples, before prefixItems was available
163156
# MAINTENANCE: items: Optional["SchemaOrBool"] = None
157+
items: Union["SchemaOrBool", list["SchemaOrBool"]] | None = None
158+
contains: "SchemaOrBool | None" = None
164159
properties: dict[str, "SchemaOrBool"] | None = None
165160
patternProperties: dict[str, "SchemaOrBool"] | None = None
166161
additionalProperties: "SchemaOrBool | None" = None
@@ -332,9 +327,9 @@ class Operation(OpenAPIExtensions):
332327
operationId: str | None = None
333328
parameters: list[Union[Parameter, Reference]] | None = None
334329
requestBody: Union[RequestBody, Reference] | None = None
330+
# Using Any for Specification Extensions
335331
responses: dict[int, Union[Response, Any]] | None = None
336332
callbacks: dict[str, Union[dict[str, "PathItem"], Reference]] | None = None
337-
# Using Any for Specification Extensions
338333
deprecated: bool | None = None
339334
security: list[dict[str, list[str]]] | None = None
340335
servers: list[Server] | None = None
@@ -462,10 +457,10 @@ class Components(BaseModel):
462457
headers: dict[str, Union[Header, Reference]] | None = None
463458
securitySchemes: dict[str, Union[SecurityScheme, Reference]] | None = None
464459
links: dict[str, Union[Link, Reference]] | None = None
460+
# Using Any for Specification Extensions
465461
callbacks: dict[str, Union[dict[str, PathItem], Reference, Any]] | None = None
466462
pathItems: dict[str, Union[PathItem, Reference]] | None = None
467463

468-
# Using Any for Specification Extensions
469464
model_config = MODEL_CONFIG_ALLOW
470465

471466

@@ -475,9 +470,9 @@ class OpenAPI(OpenAPIExtensions):
475470
info: Info
476471
jsonSchemaDialect: str | None = None
477472
servers: list[Server] | None = None
473+
# Using Any for Specification Extensions
478474
paths: dict[str, Union[PathItem, Any]] | None = None
479475
webhooks: dict[str, Union[PathItem, Reference]] | None = None
480-
# Using Any for Specification Extensions
481476
components: Components | None = None
482477
security: list[dict[str, list[str]]] | None = None
483478
tags: list[Tag] | None = None

0 commit comments

Comments
 (0)