Property Not Unique

  • Query id: 750b40be-4bac-4f59-bdc4-1ca0e6c3450e
  • Query name: Property Not Unique
  • Platform: OpenAPI
  • Severity: Info
  • Category: Structure and Semantics
  • URL: Github

Description

Every defined property must be unique throughout the whole API
Documentation

Code samples

Code samples with security vulnerabilities

Positive test num. 1 - json file
{
  "swagger": "2.0",
  "info": {
    "title": "Simple API Overview",
    "version": "1.0.0"
  },
  "basePath": "/api",
  "paths": {
    "/": {
      "get": {
        "operationId": "listVersionsv2",
        "summary": "List API versions",
        "responses": {
          "200": {
            "description": "200 response"
          }
        },
        "parameters": [
          {
            "name": "limit2",
            "in": "body",
            "description": "max records to return",
            "required": true,
            "schema": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "address": {
                  "$ref": "#/definitions/Address"
                },
                "age": {
                  "type": "integer",
                  "format": "int32"
                }
              }
            }
          }
        ]
      }
    }
  },
  "parameters": {
    "limitParam": {
      "name": "limit",
      "in": "body",
      "description": "max records to return",
      "required": true,
      "schema": {
        "type": "object"
      },
      "properties": {
        "name": {
          "type": "string"
        },
        "address": {
          "$ref": "#/definitions/Address"
        },
        "age": {
          "type": "integer",
          "format": "int32"
        }
      }
    }
  }
}
Positive test num. 2 - yaml file
swagger: "2.0"
info:
  title: Simple API Overview
  version: 1.0.0
basePath: "/api"
paths:
  "/":
    get:
      operationId: listVersionsv2
      summary: List API versions
      responses:
        "200":
          description: 200 response
      parameters:
        - name: limit2
          in: body
          description: max records to return
          required: true
          schema:
            type: object
            properties:
              name:
                type: string
              address:
                $ref: "#/definitions/Address"
              age:
                type: integer
                format: int32
parameters:
  limitParam:
    name: limit
    in: body
    description: max records to return
    required: true
    schema:
      type: object
    properties:
      name:
        type: string
      address:
        $ref: "#/definitions/Address"
      age:
        type: integer
        format: int32

Code samples without security vulnerabilities

Negative test num. 1 - json file
{
  "swagger": "2.0",
  "info": {
    "title": "Simple API Overview",
    "version": "1.0.0"
  },
  "basePath": "/api",
  "paths": {
    "/": {
      "get": {
        "operationId": "listVersionsv2",
        "summary": "List API versions",
        "responses": {
          "200": {
            "description": "200 response"
          }
        },
        "parameters": [
          {
            "name": "limit2",
            "in": "body",
            "description": "max records to return",
            "required": true,
            "schema": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "address": {
                  "$ref": "#/definitions/Address"
                },
                "age": {
                  "type": "integer",
                  "format": "int32"
                }
              }
            }
          }
        ]
      }
    }
  },
  "parameters": {
    "limitParam": {
      "name": "limit",
      "in": "body",
      "description": "max records to return",
      "required": true,
      "schema": {
        "type": "object"
      },
      "properties": {
        "name_2": {
          "type": "string"
        },
        "address_2": {
          "$ref": "#/definitions/Address"
        },
        "age_2": {
          "type": "integer",
          "format": "int32"
        }
      }
    }
  }
}
Negative test num. 2 - yaml file
swagger: "2.0"
info:
  title: Simple API Overview
  version: 1.0.0
basePath: "/api"
paths:
  "/":
    get:
      operationId: listVersionsv2
      summary: List API versions
      responses:
        "200":
          description: 200 response
      parameters:
        - name: limit2
          in: body
          description: max records to return
          required: true
          schema:
            type: object
            properties:
              name:
                type: string
              address:
                $ref: "#/definitions/Address"
              age:
                type: integer
                format: int32
parameters:
  limitParam:
    name: limit
    in: body
    description: max records to return
    required: true
    schema:
      type: object
    properties:
      name_2:
        type: string
      address_2:
        $ref: "#/definitions/Address"
      age_2:
        type: integer
        format: int32