Swagger error - should have only three digit status codes

I am building a Swagger documentation for an API in Swagger Editor and I have this error :

should only have three-digit status codes, `default`, and vendor extensions (`x-*`) as properties

This is the swagger code:

/stareMesaj:
    post:
      tags:
        - Metode disponibile
      summary: Stare mesaj
      description: Call de upload mesaj. More soon.
      operationId: stareMesaj
      responses:
        '200':
          description: 1.Ultimele 60 zile -  Nu aveti drept de interogare stare pentru
            mesaj/ 2.Mai mult de 60 zile -  Formularul cu id de incarcare= xxx a
            fost depus de mai mult de 60 de zile 3. Id maxim -  Nu aveti drept
            de interogare stare pentru mesaj= max id
          headers:
        X-Rate-Limit:
          description: calls per hour allowed by the user
          schema:
            type: integer
            format: int32

The error appears on this line :

responses:
Just before '200'

What might be the problem ? The status code is obviously three digit code

Thanks

I see that this has been asked and answered at https://stackoverflow.com/questions/59369564/swagger-error-should-have-only-three-digit-status-codes

I posted that question and it doesnt work

Swagger thinks that X-Rate-Limit: is one of your response codes.

You were instructed last month how to fix that.
You fix that by making corrections to the text indent. The indent matters.

In greater detail.

Currently your Header parameter has an indent of 10 spaces, and the X-Rate-Limit parameter has an indent of 8 spaces.

          headers:
        X-Rate-Limit:
          description: calls per hour allowed by the user
          schema:
            type: integer
            format: int32

That causes Swagger to think that X-Rate-Limit belongs with the parent of Header, which is the responses parameter.

You are getting an error message telling you that the responses parameter has an invalid status code. That’s because Swagger mistakenly thinks that you are attempting to use X-Rate-Limit as a responses status code.

Instead, you need X-Rate-Limit to be a child of the headers parameter, which is achieved by adding more spaces in front of the X-Rate-Limit section so that it becomes indented underneath the headers section.

For example:

          headers:
            X-Rate-Limit:
              description: calls per hour allowed by the user
              schema:
                type: integer
                format: int32

Did you do what was recommended? If so, your example hasn’t demonstrated it.

Once you have made the appropriate adjustment, and you get the same or a different error, please supply the full error message instead of just an excerpt.

Thanks.

I made it work thanks

1 Like

To be clear, those are spaces and not tabs? Doesn’t matter?

It uses Markdown format so as long as it’s consistent, it doesn’t matter.

What does matter though is that it’s a web form interface that you’re entering it to, so spaces are more reliable than tabs.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.