Skip to content

bug: Define consumes property in Swagger 2.0 when the request is a GET rules [OAR006;OAR009] #41

@dariocloudappi

Description

@dariocloudappi

I have been reviewing a Swagger 2.0 API and came across these two rules, which are OAR006 and OAR009

OAR009 - DefaultRequestMediaType - Must indicate the default request media type
OAR006 - UndefinedRequestMediaType - APIs must define the request media types supported by the API

Both rules appear when specifying a GET and, therefore, appear when the consumes property is not specified with a set value (json, xml, etc.), but when reviewing the documentation https://swagger.io/docs/specification/v2_0/mime-types/ this property only defines when input data will be received by the body (PUT, POST, PATCH). I understand that, if we follow best practices, a GET method will never expect a body, it would be avoided as much as possible, so I understand that these are not rules that should be activated when defining an endpoint with the GET method.

Current behavior:

Shows errors when the consumes property is not defined in a get operation in Swagger 2.0 , with rules OAR006 and OAR009

Expected behavior:

When it comes to a GET method, the keyword consumes does not have to be defined, so rules OAR006 and OAR009 should not show me errors if the operation is a GET method.

Steps to reproduce:

  1. Define an API with Swagger 2.0, and define an operation with the GET method, without defining the consumes property.
  2. View the errors that are displayed.

Metadata

Metadata

Assignees

No one assigned

    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