[PR #4478] [MERGED] feat: openapi 422 response #5401

Closed
opened 2026-03-13 12:21:37 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4478
Author: @Z377A1
Created: 9/5/2025
Status: Merged
Merged: 9/7/2025
Merged by: @Bekacru

Base: canaryHead: feat/openapi-422-response


📝 Commits (4)

  • 4c3cc2c feat: add and enhance 422 Unprocessable Content response
  • aa0a980 fix: update description from "Unprocessable Content" to "Unprocessable Entity" for 422 responses
  • 05c6d8f fix: format description for 422 response
  • c6bec92 fix: remove unnecessary entries from .gitignore

📊 Changes

3 files changed (+46 additions, -0 deletions)

View changed files

📝 packages/better-auth/src/api/routes/sign-up.ts (+16 -0)
📝 packages/better-auth/src/api/routes/update-user.ts (+15 -0)
📝 packages/better-auth/src/plugins/username/index.ts (+15 -0)

📄 Description

This adds the 422 Unprocessable Content response to the OpenAPI specification for the following endpoints:

  • /sign-up/email
  • /update-user
  • /sign-in/username

The 422 Unprocessable Content response is used to indicate that the server understood the request but was unable to process it due to semantic errors, such as:

  • Attempting to sign up with an existing email.
  • Attempting to sign up with an invalid username.
  • Other validation errors that fall under the UNPROCESSABLE_ENTITY APIError.

Changes Made

  1. Updated the OpenAPI spec to include the 422 response for the endpoints that include the 422 Unprocessable Content responses.

Documentation Reference

For more details on the 422 Unprocessable Content status code, see the MDN documentation.


Summary by cubic

Added 422 Unprocessable Entity responses to the OpenAPI spec for sign-up, update-user, and username sign-in routes to document validation errors and improve client error handling.

  • New Features - New features added
    • Documented 422 responses for: /sign-up/email, /update-user, and /sign-in/username.
    • Response schema: application/json with { message: string }.
    • Standardized description to “Unprocessable Entity.”

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/4478 **Author:** [@Z377A1](https://github.com/Z377A1) **Created:** 9/5/2025 **Status:** ✅ Merged **Merged:** 9/7/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `feat/openapi-422-response` --- ### 📝 Commits (4) - [`4c3cc2c`](https://github.com/better-auth/better-auth/commit/4c3cc2c5bfbef87756234b80810cb2e257f28f86) feat: add and enhance 422 Unprocessable Content response - [`aa0a980`](https://github.com/better-auth/better-auth/commit/aa0a98025c97b792c0fdd8a1f9438cf21c6b2b4f) fix: update description from "Unprocessable Content" to "Unprocessable Entity" for 422 responses - [`05c6d8f`](https://github.com/better-auth/better-auth/commit/05c6d8fe8793ff40b4a4adfdd9fa35e68cc11d16) fix: format description for 422 response - [`c6bec92`](https://github.com/better-auth/better-auth/commit/c6bec921c237ec95ac4f5dfa5518b02b591845da) fix: remove unnecessary entries from .gitignore ### 📊 Changes **3 files changed** (+46 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/api/routes/sign-up.ts` (+16 -0) 📝 `packages/better-auth/src/api/routes/update-user.ts` (+15 -0) 📝 `packages/better-auth/src/plugins/username/index.ts` (+15 -0) </details> ### 📄 Description This adds the `422 Unprocessable Content` response to the OpenAPI specification for the following endpoints: - `/sign-up/email` - `/update-user` - `/sign-in/username` The `422 Unprocessable Content` response is used to indicate that the server understood the request but was unable to process it due to semantic errors, such as: - Attempting to sign up with an existing email. - Attempting to sign up with an invalid username. - Other validation errors that fall under the UNPROCESSABLE_ENTITY APIError. #### Changes Made 1. Updated the OpenAPI spec to include the `422` response for the endpoints that include the `422 Unprocessable Content` responses. #### Documentation Reference For more details on the `422 Unprocessable Content` status code, see the [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/422). <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Added 422 Unprocessable Entity responses to the OpenAPI spec for sign-up, update-user, and username sign-in routes to document validation errors and improve client error handling. - New Features - New features added - Documented 422 responses for: /sign-up/email, /update-user, and /sign-in/username. - Response schema: application/json with { message: string }. - Standardized description to “Unprocessable Entity.” <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 12:21:37 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#5401