Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Openapi 2.0 (swagger) semantic validations #223

Open
eguzki opened this issue Nov 4, 2019 · 0 comments
Open

Openapi 2.0 (swagger) semantic validations #223

eguzki opened this issue Nov 4, 2019 · 0 comments

Comments

@eguzki
Copy link
Member

eguzki commented Nov 4, 2019

Currently, toolbox validates swagger spec content at the following levels:

There are semantic validations not done to check, for instance, duplicated operationId, reported in issue #222

The following swagger spec passes current validation system of the toolbox, however it is not a valid swagger schema.

swagger: "2.0"
info:
  version: v1
  title: WebApplication1
host: localhost:3873
schemes:
- http
paths:
  /api/User:
    get:
      tags:
      - User
      operationId: User_Get
      consumes: []
      produces:
      - application/json
      - text/json
      - application/xml
      - text/xml
      responses:
        "200":
          description: OK
          schema:
            type: array
            items:
              type: string
  /api/User/{id}:
    get:
      tags:
      - User
      operationId: User_Get
      consumes: []
      produces:
      - application/json
      - text/json
      - application/xml
      - text/xml
      parameters:
      - name: id
        in: path
        required: true
        type: integer
        format: int32
      responses:
        "200":
          description: OK
          schema:
            type: string

Swagger spec makes it very clear that

Unique string used to identify the operation. 
The id MUST be unique among all operations described in the API. 
Tools and libraries MAY use the operationId to uniquely identify an operation, therefore, it is recommended to follow common programming naming conventions.

Semantic validations should be implemented to reject invalid swagger docs. Source for semantic validations: https://github.com/swagger-api/swagger-editor/tree/master/src/plugins/validate-semantic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant