Codit / practical-api-guidelines

Practical guidelines for building & designing APIs with .NET.
MIT License
16 stars 5 forks source link

Enforce lowercase URLs #27

Closed tomkerkhove closed 6 years ago

tomkerkhove commented 6 years ago

Relates to #19

Generated OpenAPI

{
  "swagger": "2.0",
  "info": {
    "version": "v1",
    "title": "World Cup API",
    "description": "World cup 2018 Russia",
    "termsOfService": "N/A",
    "contact": {
      "name": "API at Codit",
      "url": "www.codit.eu",
      "email": "support@codit.eu"
    }
  },
  "paths": {
    "/world-cup/v{version}/players": {
      "get": {
        "tags": [
          "Players"
        ],
        "operationId": "World-cupV{versionPlayersGet",
        "consumes": [],
        "produces": [],
        "parameters": [
          {
            "name": "top-players-only",
            "in": "query",
            "required": false,
            "type": "boolean"
          },
          {
            "name": "version",
            "in": "path",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "Success"
          },
          "500": {
            "description": "Server Error"
          }
        }
      },
      "post": {
        "tags": [
          "Players"
        ],
        "operationId": "World-cupV{versionPlayersPost",
        "consumes": [
          "application/json-patch+json",
          "application/json",
          "text/json",
          "application/*+json"
        ],
        "produces": [],
        "parameters": [
          {
            "name": "player",
            "in": "body",
            "required": false,
            "schema": {
              "$ref": "#/definitions/Player"
            }
          },
          {
            "name": "version",
            "in": "path",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "201": {
            "description": "Success"
          },
          "500": {
            "description": "Server Error"
          }
        }
      }
    },
    "/world-cup/v{version}/players/{id}/vote": {
      "post": {
        "tags": [
          "Players"
        ],
        "operationId": "World-cupV{versionPlayersByIdVotePost",
        "consumes": [],
        "produces": [],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "integer",
            "format": "int32"
          },
          {
            "name": "version",
            "in": "path",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "204": {
            "description": "Success"
          },
          "404": {
            "description": "Not Found"
          },
          "500": {
            "description": "Server Error"
          }
        }
      }
    },
    "/world-cup/v{version}/players/{id}": {
      "get": {
        "tags": [
          "Players"
        ],
        "operationId": "World-cupV{versionPlayersByIdGet",
        "consumes": [],
        "produces": [],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "integer",
            "format": "int32"
          },
          {
            "name": "version",
            "in": "path",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "Success"
          },
          "404": {
            "description": "Not Found"
          },
          "500": {
            "description": "Server Error"
          }
        }
      },
      "put": {
        "tags": [
          "Players"
        ],
        "operationId": "World-cupV{versionPlayersByIdPut",
        "consumes": [
          "application/json-patch+json",
          "application/json",
          "text/json",
          "application/*+json"
        ],
        "produces": [],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "integer",
            "format": "int32"
          },
          {
            "name": "player",
            "in": "body",
            "required": false,
            "schema": {
              "$ref": "#/definitions/PlayerDto"
            }
          },
          {
            "name": "version",
            "in": "path",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "204": {
            "description": "Success"
          },
          "404": {
            "description": "Not Found"
          },
          "500": {
            "description": "Server Error"
          }
        }
      },
      "patch": {
        "tags": [
          "Players"
        ],
        "operationId": "World-cupV{versionPlayersByIdPatch",
        "consumes": [
          "application/json-patch+json",
          "application/json",
          "text/json",
          "application/*+json"
        ],
        "produces": [],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "integer",
            "format": "int32"
          },
          {
            "name": "player",
            "in": "body",
            "required": false,
            "schema": {
              "$ref": "#/definitions/PlayerDto"
            }
          },
          {
            "name": "version",
            "in": "path",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "204": {
            "description": "Success"
          },
          "404": {
            "description": "Not Found"
          },
          "500": {
            "description": "Server Error"
          }
        }
      }
    },
    "/world-cup/v{version}/players/{id}/update": {
      "patch": {
        "tags": [
          "Players"
        ],
        "operationId": "World-cupV{versionPlayersByIdUpdatePatch",
        "consumes": [
          "application/json-patch+json",
          "application/json",
          "text/json",
          "application/*+json"
        ],
        "produces": [],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "integer",
            "format": "int32"
          },
          {
            "name": "player",
            "in": "body",
            "required": false,
            "schema": {
              "uniqueItems": false,
              "type": "array",
              "items": {
                "$ref": "#/definitions/Operation"
              }
            }
          },
          {
            "name": "version",
            "in": "path",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "204": {
            "description": "Success"
          },
          "404": {
            "description": "Not Found"
          },
          "500": {
            "description": "Server Error"
          }
        }
      }
    },
    "/world-cup/v{version}/teams": {
      "get": {
        "tags": [
          "Teams"
        ],
        "operationId": "World-cupV{versionTeamsGet",
        "consumes": [],
        "produces": [],
        "parameters": [
          {
            "name": "version",
            "in": "path",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "Success"
          },
          "500": {
            "description": "Server Error"
          }
        }
      }
    },
    "/world-cup/v{version}/teams/{id}": {
      "get": {
        "tags": [
          "Teams"
        ],
        "operationId": "World-cupV{versionTeamsByIdGet",
        "consumes": [],
        "produces": [],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "integer",
            "format": "int32"
          },
          {
            "name": "version",
            "in": "path",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "Success"
          },
          "404": {
            "description": "Not Found"
          },
          "500": {
            "description": "Server Error"
          }
        }
      }
    },
    "/world-cup/v{version}/values": {
      "get": {
        "tags": [
          "Values"
        ],
        "operationId": "World-cupV{versionValuesGet",
        "consumes": [],
        "produces": [
          "text/plain",
          "application/json",
          "text/json"
        ],
        "parameters": [
          {
            "name": "version",
            "in": "path",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "schema": {
              "uniqueItems": false,
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Values"
        ],
        "operationId": "World-cupV{versionValuesPost",
        "consumes": [
          "application/json-patch+json",
          "application/json",
          "text/json",
          "application/*+json"
        ],
        "produces": [],
        "parameters": [
          {
            "name": "value",
            "in": "body",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "version",
            "in": "path",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      }
    },
    "/world-cup/v{version}/values/{id}": {
      "get": {
        "tags": [
          "Values"
        ],
        "operationId": "World-cupV{versionValuesByIdGet",
        "consumes": [],
        "produces": [
          "text/plain",
          "application/json",
          "text/json"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "integer",
            "format": "int32"
          },
          {
            "name": "version",
            "in": "path",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "schema": {
              "type": "string"
            }
          }
        }
      },
      "put": {
        "tags": [
          "Values"
        ],
        "operationId": "World-cupV{versionValuesByIdPut",
        "consumes": [
          "application/json-patch+json",
          "application/json",
          "text/json",
          "application/*+json"
        ],
        "produces": [],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "integer",
            "format": "int32"
          },
          {
            "name": "value",
            "in": "body",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "version",
            "in": "path",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      },
      "delete": {
        "tags": [
          "Values"
        ],
        "operationId": "World-cupV{versionValuesByIdDelete",
        "consumes": [],
        "produces": [],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "integer",
            "format": "int32"
          },
          {
            "name": "version",
            "in": "path",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      }
    }
  },
  "definitions": {
    "Player": {
      "required": [
        "firstName"
      ],
      "type": "object",
      "properties": {
        "id": {
          "format": "int32",
          "type": "integer"
        },
        "firstName": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "isTopPlayer": {
          "type": "boolean"
        },
        "team": {
          "$ref": "#/definitions/Team"
        },
        "teamId": {
          "format": "int32",
          "type": "integer"
        }
      }
    },
    "Team": {
      "required": [
        "name"
      ],
      "type": "object",
      "properties": {
        "id": {
          "format": "int32",
          "type": "integer"
        },
        "name": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "ranking": {
          "format": "int32",
          "type": "integer"
        },
        "firstAppearence": {
          "format": "int32",
          "type": "integer"
        },
        "totalWins": {
          "format": "int32",
          "type": "integer"
        },
        "continent": {
          "enum": [
            "Asia",
            "Africa",
            "NorthAmerica",
            "SouthAmerica",
            "Europe",
            "Australia"
          ],
          "type": "string"
        },
        "updatedOn": {
          "format": "date-time",
          "type": "string"
        },
        "players": {
          "uniqueItems": false,
          "type": "array",
          "items": {
            "$ref": "#/definitions/Player"
          }
        }
      }
    },
    "PlayerDto": {
      "type": "object",
      "properties": {
        "id": {
          "format": "int32",
          "type": "integer"
        },
        "firstName": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "isTopPlayer": {
          "type": "boolean"
        },
        "teamId": {
          "format": "int32",
          "type": "integer"
        }
      }
    },
    "Operation": {
      "type": "object",
      "properties": {
        "value": {
          "type": "object"
        },
        "path": {
          "type": "string"
        },
        "op": {
          "type": "string"
        },
        "from": {
          "type": "string"
        }
      }
    }
  }
}