Skip to content

05 Method Not Allowed response instead of 400 with incorrect validation details #2598

@denis1989java

Description

@denis1989java

Hello

Problem statement

I have api endpoint in my app. Interface was generated from rest-api.yaml:

swagger: '2.0'
info:
  title: inv REST API
  description: inv
  version: 1.0.0
  contact:
    name: lbn@sap.com
schemes:
  - https
produces:
  - application/json

paths:
  /inv/v1/invApi:
    post:
      operationId: createInv
      summary: Public API for inv
      description: |
        Create a new inv
      tags:
        - Inv
      parameters:
        - name: inv
          in: body
          description: A inv
          required: true
          schema:
            $ref: '#/definitions/InvRest'
      responses:
        '201':
          description: inv is created
        '400':
          description: Malformed payload
          schema:
            type: array
            items:
              $ref: '#/definitions/Error'
        '409':
          description: Error during validation
          schema:
            type: array
            items:
              $ref: '#/definitions/Error'

definitions:
  InvRest:
    type: object
    required:
      - InvID
    properties:
      InvID:
        type: string
        maxLength: 3

On making requests if InvID provided in payload everything works fine.
But if it isn't provided in payload I expect to get 400 response code and message that InvID is not provided.
But I get 405 Method Not Allowed.

Environment

swagger version: '2.0'
java 8
spring boot

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions