fix: get response example return type #792
Merged
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.
🧰 Changes
Hey 👋 I was using the library and noticed that the
getResponseExamples()
declares to use incorrect type. The returned data is not in the shape the type definition claims.The function casts the returned type incorrectly in L68. The used type is shaped like
but the code actually transforms it into type shaped like
The actually used type is defined in L28 which is then returned from the
getResponseExamples()
in L56.The type is also missing
onlyHeaders?: boolean
which is added conditionally in L57.Taking a look at the tests
for
getResponseExamples()
reveals that themediaTypes
type is expected to beRecord<string, MediaTypeExample[]>
instead ofRecord<string, RMOAS.MediaTypeObject>
. The used tests data doesn't conform toRMOAS.MediaTypeObject
's shape.🧬 QA & Testing
Since the change is about the types there wasn't any changes to the existing tests. The tests ran green before the change and after change.