feat(Endpoint): Add title and description attributes to Endpoint attribute#1007
Merged
romalytvynenko merged 3 commits intodedoc:mainfrom Dec 28, 2025
Merged
feat(Endpoint): Add title and description attributes to Endpoint attribute#1007romalytvynenko merged 3 commits intodedoc:mainfrom
romalytvynenko merged 3 commits intodedoc:mainfrom
Conversation
Add new title and description fields to Endpoint attribute to allow setting endpoint metadata directly. Update operation extensions to handle these new fields while maintaining backward compatibility with PHPDoc fallbacks. Add tests for new functionality.
Member
|
Hey @mikield Thanks for the PR. Released the feature in https://github.com/dedoc/scramble/releases/tag/v0.13.10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for
titleanddescriptionparameters to theEndpointattribute, allowing developers to set custom OpenAPI operation summaries and descriptions directly via the attribute.Changes Made
1. Enhanced Endpoint Attribute
src/Attributes/Endpoint.phptitleanddescriptionproperties to theEndpointattributetitlemaps to OpenAPIsummaryfielddescriptionmaps to OpenAPIdescriptionfield2. Updated RequestEssentialsExtension
src/Support/OperationExtensions/RequestEssentialsExtension.phpsetTitleAndDescriptionFromEndpointAttribute()methodEndpointattribute and sets them on the operation3. Fixed RequestBodyExtension Override Issue
src/Support/OperationExtensions/RequestBodyExtension.phpEndpointattribute)Endpointattribute values from being overriddenUsage Examples
Basic Title
Title and Description
#[Endpoint( title: 'Create New User', description: 'Creates a new user account with the provided information' )] public function store(CreateUserRequest $request) { // ... }Combined with Operation ID
#[Endpoint( operationId: 'users.update', title: 'Update User', description: 'Updates an existing user with new information' )] public function update(UpdateUserRequest $request, User $user) { // ... }Testing
All existing tests continue to pass, and new tests have been added to verify:
EndpointattributeEndpointattributeoperationIdfunctionalityEndpointattribute values take priority over PHPDoc commentsTechnical Details
Extension Execution Order
The fix addresses an issue where
RequestBodyExtensionwas running afterRequestEssentialsExtensionand unconditionally overriding the operation's summary and description with PHPDoc values. The solution ensures that:RequestEssentialsExtensionsets title/description fromEndpointattributeRequestBodyExtensiononly sets values from PHPDoc if not already setEndpointattribute values take precedence over PHPDoc commentsOpenAPI Mapping
Endpoint::$title→ OpenAPIsummaryEndpoint::$description→ OpenAPIdescriptionThis follows OpenAPI 3.0 specification where:
summaryis a short summary of what the operation doesdescriptionis a verbose explanation of the operation behaviorBackward Compatibility
This change is fully backward compatible:
Endpointattributes continue to work unchangedEndpointattributes don't specify title/descriptionRelated Issues
This enhancement improves the developer experience by allowing more granular control over OpenAPI documentation directly through attributes, reducing the need for PHPDoc comments for basic operation metadata.