Skip to content

Custom HTTP status codes should not be marked as issues #153

@Herrick19

Description

@Herrick19

Hi,

I have defined a status code 352 as a response in a path like this

description: ''
get:
    tags:
        - Object_Activesession
    responses:
        '200':
            content:
                application/json:
                    schema:
                        $ref: '#/components/schemas/activesession-getCurrent-v1-Response'
            description: OK
        '352':
            $ref: '#/components/responses/Response-Redirect-352'
    security:
        -
            Authorization: []
    operationId: Activesession_GetCurrent_V1
    summary: Get Current Activesession
    description: Retrieve the details about the current activesession

Apicurito marks the 352 as an issue with this message:

"352" is not a valid HTTP response status code.
All Responses declared for an Operation must correspond to a valid HTTP response status code. Valid status codes are things like 200, 404, 500. A full list of status codes can be found here: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

I've read these pages:
https://swagger.io/specification/
https://datatracker.ietf.org/doc/html/rfc7231#section-6
https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

And nowhere I can see that we MUST NOT use a custom code.

If you read this section:
https://datatracker.ietf.org/doc/html/rfc7231#section-6

We can read:

HTTP status codes are extensible.  HTTP clients are not required to
   understand the meaning of all registered status codes, though such
   understanding is obviously desirable.  However, a client MUST
   understand the class of any status code, as indicated by the first
   digit, and treat an unrecognized status code as being equivalent to
   the x00 status code of that class, with the exception that a
   recipient MUST NOT cache a response with an unrecognized status code.

   For example, if an unrecognized status code of 471 is received by a
   client, the client can assume that there was something wrong with its
   request and treat the response as if it had received a 400 (Bad
   Request) status code.  The response message will usually contain a
   representation that explains the status.

So my opinion is that Apicurito is flagging this an an issue when it should not since the codes are extensibles so we can put anything we want in there.

It's an easy fix it you are accepting this change since it's just a matter of removing a test for you.

By the way, redoc will show the 352 redirect response correctly without any complaint.

Thanks for considering this fix.

Best Regards

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions