Skip to content

Conversation

simonjbeaumont
Copy link
Collaborator

Motivation

When the server response has a content-type header that does not conform to the OpenAPI document, we currently throw an error. However, this error presents itself in a very confusing manner: it prints Unexpected Content-Type header: application/json, where `application/json is the expected content-type. At best, this is ambiguous and potentially misleading.

Modifications

  • Extend case RuntimeError.unexpectedContentTypeHeader with both the expected and received content-type associated values.
  • Update the printed description to include both the expected and received content-type header values.

Result

When an unexpected content-type is received, the error message is clearer.

Test Plan

Updated the existing test that expects an error to check the error and that the error values are provided in the correct order.

Copy link
Contributor

@czechboy0 czechboy0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice quality of life improvement! 👏

@czechboy0 czechboy0 merged commit 9d4a2ff into apple:main Apr 9, 2024
@czechboy0 czechboy0 added the 🔨 semver/patch No public API change. label Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 semver/patch No public API change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants