Skip to content

Swagger Parser Does Not Validate Missing Version Field #2169

Closed
@sachin-smartbear

Description

@sachin-smartbear

According to the OpenAPI/Swagger documentation, the version field in the API definition is mandatory. However, when parsing an API definition that does not include the version field, the Swagger parser does not throw any error or warning.

Steps to Reproduce:

  1. Use the Swagger Parser library to parse the following API definition:
swagger: "2.0"
info:
  title: Test API
  version:  # Missing version field
paths:
  /:
    get:
      summary: List API versions
      produces:
        - application/json
      responses:
        "200":
          description: Successful response
        "300":
          description: Multiple choices response
  /v2:
    get:
      summary: Show API version details
      produces:
        - application/json
      responses:
        "200":
          description: Successful response
        "203":
          description: Non-authoritative information
consumes:
  - application/json
  1. Observe that the parser does not report any validation errors or warnings.

Expected Behavior:
The parser should throw an error or at least a warning indicating that the version field is missing since it is mandatory.

Actual Behavior:
the missing version field in info should trigger a validation error, but it does not.

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