﻿{
  "openapi": "3.0.4",
  "info": {
    "title": "Test API V1",
    "version": "v1"
  },
  "servers": [
    {
      "url": "/resource-server"
    }
  ],
  "paths": {
    "/products": {
      "get": {
        "tags": [
          "Products"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Product"
                  }
                }
              },
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Product"
                  }
                }
              },
              "text/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Product"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden"
          }
        },
        "security": [
          {
            "oauth2": [
              "readAccess"
            ]
          }
        ]
      },
      "post": {
        "tags": [
          "Products"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Product"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/Product"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/Product"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden"
          }
        },
        "security": [
          {
            "oauth2": [
              "writeAccess"
            ]
          }
        ]
      }
    },
    "/products/{id}": {
      "get": {
        "tags": [
          "Products"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/Product"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Product"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/Product"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden"
          }
        },
        "security": [
          {
            "oauth2": [
              "readAccess"
            ]
          }
        ]
      },
      "delete": {
        "tags": [
          "Products"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden"
          }
        },
        "security": [
          {
            "oauth2": [
              "writeAccess"
            ]
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "Product": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32",
            "readOnly": true
          },
          "serialNo": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "$ref": "#/components/schemas/ProductStatus"
          }
        },
        "additionalProperties": false
      },
      "ProductStatus": {
        "enum": [
          0,
          1
        ],
        "type": "integer",
        "format": "int32"
      }
    },
    "securitySchemes": {
      "oauth2": {
        "type": "oauth2",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "/auth-server/connect/authorize",
            "tokenUrl": "/auth-server/connect/token",
            "scopes": {
              "readAccess": "Access read operations",
              "writeAccess": "Access write operations"
            }
          }
        }
      }
    }
  },
  "security": [
    {
      "oauth2": [
        "readAccess",
        "writeAccess"
      ]
    }
  ],
  "tags": [
    {
      "name": "Products"
    }
  ]
}