[X] I have searched existing issues to ensure the bug has not already been reported
Fastify version
5.0.0
Plugin version
3.0.1
Node.js version
22.10.0
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
Ubuntu 24.04
Description
The response validator is throwing exceptions when unable to find response code if using responseStatusCodeValidation: true. This is expected; however, the plugin is incorrectly checking for 4xx when pattern matching, which should be defined as 4XX. Additionally the plugin does not consider the default response when validating.
Any HTTP status code can be used as the property name, but only one property per code, to describe the expected response for that HTTP status code. This field MUST be enclosed in quotation marks (for example, "200") for compatibility between JSON and YAML. To define a range of response codes, this field MAY contain the uppercase wildcard character X. For example, 2XX represents all response codes between [200-299]. Only the following range definitions are allowed: 1XX, 2XX, 3XX, 4XX, and 5XX. If a response is defined using an explicit code, the explicit code definition takes precedence over the range definition for that code.
Prerequisites
Fastify version
5.0.0
Plugin version
3.0.1
Node.js version
22.10.0
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
Ubuntu 24.04
Description
The response validator is throwing exceptions when unable to find response code if using
responseStatusCodeValidation: true
. This is expected; however, the plugin is incorrectly checking for4xx
when pattern matching, which should be defined as4XX
. Additionally the plugin does not consider thedefault
response when validating.Relevant text from the OpenAPI standard:
The documentation from the OpenAPI-Specification can be found here: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#responses-object
The documentation for swagger is the same and can be found here: https://swagger.io/specification/#fixed-fields-14
Link to code that reproduces the bug
See Test Cases In PR
Expected Behavior
Expected behavior matching the defined standard.