Skip to content

feat(event_handler): add Cookie parameter support for OpenAPI utility#8095

Merged
leandrodamascena merged 2 commits intodevelopfrom
feat/3691-cookie-parameter-support
Apr 6, 2026
Merged

feat(event_handler): add Cookie parameter support for OpenAPI utility#8095
leandrodamascena merged 2 commits intodevelopfrom
feat/3691-cookie-parameter-support

Conversation

@leandrodamascena
Copy link
Copy Markdown
Contributor

Issue number: closes #3691

Summary

Customers can now use cookies as typed, validated parameters in your API endpoints - just like Query(), Header(), or Form(). The OpenAPI schema generates in: cookie parameters, and validation works across all six resolver types.

Changes

Please provide a summary of what's being changed

User experience

from typing import Annotated
from aws_lambda_powertools.event_handler import APIGatewayRestResolver
from aws_lambda_powertools.event_handler.openapi.params import Cookie

app = APIGatewayRestResolver(enable_validation=True)

@app.get("/me")
def get_me(
    session_id: Annotated[str, Cookie(description="Session identifier")],
    theme: Annotated[str, Cookie(description="UI theme")] = "light",
):
    return {"session_id": session_id, "theme": theme}

Combining Cookie with Query and Header

from aws_lambda_powertools.event_handler.openapi.params import Cookie, Header, Query

@app.get("/dashboard")
def dashboard(
    session_id: Annotated[str, Cookie()],
    page: Annotated[int, Query()] = 1,
    x_request_id: Annotated[str, Header()] = "unknown",
):
    return {"session_id": session_id, "page": page, "x_request_id": x_request_id}

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@leandrodamascena leandrodamascena requested a review from a team as a code owner April 4, 2026 17:11
@leandrodamascena leandrodamascena requested a review from sdangol April 4, 2026 17:11
@powertools-for-aws-oss-automation powertools-for-aws-oss-automation bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Apr 4, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.74%. Comparing base (ccdc52e) to head (2e224eb).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #8095   +/-   ##
========================================
  Coverage    96.73%   96.74%           
========================================
  Files          283      283           
  Lines        13881    13910   +29     
  Branches      1111     1116    +5     
========================================
+ Hits         13428    13457   +29     
  Misses         331      331           
  Partials       122      122           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@powertools-for-aws-oss-automation powertools-for-aws-oss-automation bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Apr 6, 2026
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 6, 2026

@leandrodamascena leandrodamascena merged commit 7c9589c into develop Apr 6, 2026
17 checks passed
@leandrodamascena leandrodamascena deleted the feat/3691-cookie-parameter-support branch April 6, 2026 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

event_handlers size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: Add support for cookie parameters in OpenAPI schema

2 participants