Add .empty() method to response builder for no-body responses#1797
Open
Add .empty() method to response builder for no-body responses#1797
Conversation
Open
Copilot
AI
changed the title
[WIP] Add .empty() method for responses without body
Add .empty() method to response builder for no-body responses
Apr 9, 2026
pmcelhaney
approved these changes
Apr 9, 2026
Collaborator
|
@copilot address merge conflicts |
Co-authored-by: pmcelhaney <51504+pmcelhaney@users.noreply.github.com>
Contributor
Author
Merged main and resolved the conflicts (commit b386cf4). Main had refactored |
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
Adds an
.empty()method to the response builder to explicitly signal that a response has no body. Generated handler stubs for operations with no response content now call.empty()instead of returning the bare response object.Original Prompt
Add an
.empty()method where applicable to make the fact that a response has no body more explicit.When generating code for a handler that has no response body, attach
.empty().Manual acceptance tests
DELETE /pet/{petId}) contains.empty()in the generated stub.empty()on$.response[204]returns a response with the correct status and no body.empty()after.header(...)preserves the headersGET /pet/{petId}) is unchanged and still generates.random().empty()is available on a builder for a response with no content; it is absent (type error) when content is definedTasks
empty()toResponseBuilder,WideResponseBuilder, andGenericResponseBuilderInnerinterfaces; typed as present only when[keyof Response["content"]] extends [never]empty()increateResponseBuilderas{ ...this, content: undefined }OperationCoder.write()to emit.empty()for no-body responsesoperation-coderand end-to-endgeneratetests.empty()indocs/reference.mdcounterfact-typesrefactor (one type per file with JSDoc comments); appliedempty()changes to the new individual files (response-builder.ts,wide-response-builder.ts,generic-response-builder.ts)