Skip to content

[Spector] Add 200 body / 204 no-content success response scenario #11650

Description

@JoshLove-msft

Scenario

Add an HTTP Spector scenario for an operation whose successful response may either contain a model body or contain no body:

op getLayout(): {
  @statusCode statusCode: 200;
  @body layout: BlobLayout;
} | {
  @statusCode statusCode: 204;
};

The scenario should provide test routes/cases that exercise both declared outcomes:

  • 200 OK with a valid BlobLayout response body.
  • 204 No Content with no response body.

Why

Emitters need to distinguish this from a nullable body on a single response. The operation succeeded in both cases, but one success variant has no representation. Without shared Spector coverage, emitters can accidentally deserialize the empty 204 response or expose a result type that incorrectly guarantees a value.

Validation

The scenario should allow language emitters to verify that:

  • Both 200 and 204 are classified as successful.
  • The 200 response is deserialized normally.
  • The 204 response does not attempt body deserialization.
  • Raw response status and headers remain available for both outcomes.

Metadata

Metadata

Labels

featureNew feature or requestlib:http-specsFor issues/prs related to the @typespec/http-specs package

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions