Gerne, hier ein Open API Definition. Die Felder mit <> müssten noch ausgefüllt werden.
json Copy code
{
"openapi" : "3.0.0",
"info" : {
"contact" : {
"email" : "<contact-email>"
},
"description" : "Todo API",
"license" : {
"name" : "<licence-name>",
"url" : "<link-to-licence>"
},
"termsOfService" : "<url-to-terms-of-service>",
"title" : "Todo API",
"version" : "1.0.0"
},
"externalDocs" : {
"description" : "Find out more about Swagger",
"url" : "http://swagger.io"
},
"servers" : [ {
"url" : "<url-of-the-site>"
}],
"security" : [ {
"todo_auth" : [ ]
} ],
"tags" : [ {
"description" : "Tasks",
"name" : "tasks"
} ],
"paths" : {
"/todos" : {
"get" : {
"description" : "The list of tasks can be filtered by their status.",
"operationId" : "listTodos",
"parameters" : [ {
"description" : "Filters the tasks by their status",
"explode" : true,
"in" : "query",
"name" : "status",
"required" : false,
"schema" : {
"enum" : [ "done", "waiting", "working", "all" ],
"type" : "string"
},
"style" : "form"
} ],
"responses" : {
"200" : {
"content" : {
"application/json" : {
"schema" : {
"items" : {
"$ref" : "#/components/schemas/Todo"
},
"type" : "array"
}
}
},
"description" : "successful operation"
},
"400" : {
"description" : "Invalid status value"
}
},
"security" : [ {
"todo_auth" : [ "read:todo" ]
} ],
"summary" : "List the available tasks",
"tags" : [ "tasks" ]
},
"post" : {
"description" : "Creates a todo entry",
"operationId" : "createTodo",
"requestBody" : {
"content" : {
"application/x-www-form-urlencoded" : {
"schema" : {
"$ref" : "#/components/schemas/createTodo_request"
}
}
}
},
"responses" : {
"200" : {
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/Todo"
}
}
},
"description" : "successful operation"
},
"405" : {
"description" : "Invalid input"
}
},
"security" : [ {
"todo_auth" : [ "write:todo" ]
} ],
"summary" : "Create a todo",
"tags" : [ "tasks" ]
}
},
"/todos/{todoId}" : {
"get" : {
"description" : "Get the todo",
"operationId" : "getTodo",
"parameters" : [ {
"description" : "The todo identifier",
"explode" : false,
"in" : "path",
"name" : "todoId",
"required" : true,
"schema" : {
"format" : "int64",
"type" : "integer"
},
"style" : "simple"
} ],
"responses" : {
"404" : {
"description" : "The todo does not exist."
}
},
"security" : [ {
"todo_auth" : [ "write:todo" ]
} ],
"summary" : "Get the todo",
"tags" : [ "tasks" ]
},
"delete" : {
"description" : "Delete the todo",
"operationId" : "deleteTodo",
"parameters" : [ {
"description" : "The todo identifier",
"explode" : false,
"in" : "path",
"name" : "todoId",
"required" : true,
"schema" : {
"format" : "int64",
"type" : "integer"
},
"style" : "simple"
} ],
"responses" : {
"204" : {
"description" : "No content."
},
"404" : {
"description" : "The todo does not exist."
}
},
"security" : [ {
"todo_auth" : [ "write:todo" ]
} ],
"summary" : "Delete the todo",
"tags" : [ "tasks" ]
},
"put" : {
"description" : "Update the todo title and status",
"operationId" : "updateTodo",
"parameters" : [ {
"description" : "The todo identifier",
"explode" : false,
"in" : "path",
"name" : "todoId",
"required" : true,
"schema" : {
"format" : "int64",
"type" : "integer"
},
"style" : "simple"
} ],
"requestBody" : {
"content" : {
"application/x-www-form-urlencoded" : {
"schema" : {
"$ref" : "#/components/schemas/updateTodo_request"
}
}
}
},
"responses" : {
"200" : {
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/Todo"
}
}
},
"description" : "successful operation"
},
"404" : {
"description" : "The todo does not exist."
}
},
"security" : [ {
"todo_auth" : [ "write:todo" ]
} ],
"summary" : "Update the todo",
"tags" : [ "tasks" ]
}
},
"/todos/{todoId}/check" : {
"post" : {
"description" : "Check the todo",
"operationId" : "checkTodo",
"parameters" : [ {
"description" : "The todo identifier",
"explode" : false,
"in" : "path",
"name" : "todoId",
"required" : true,
"schema" : {
"format" : "int64",
"type" : "integer"
},
"style" : "simple"
} ],
"responses" : {
"404" : {
"description" : "The todo does not exist."
}
},
"security" : [ {
"todo_auth" : [ "write:todo" ]
} ],
"summary" : "Check the todo as done",
"tags" : [ "tasks" ]
}
}
},
"components" : {
"schemas" : {
"Todo" : {
"example" : {
"id" : 23,
"title" : "Make a presentation about ChatGPT",
"description" : "Name all important points",
"status" : "working",
"create_date" : "2017-12-24T00:00:00.000Z"
},
"properties" : {
"id" : {
"description" : "The todo identifier",
"format" : "int64",
"type" : "integer"
},
"title" : {
"description" : "The todo title",
"type" : "string"
},
"create_date" : {
"description" : "The todo creation date",
"format" : "date-time",
"type" : "string"
},
"done_date" : {
"description" : "The todo resolution date",
"format" : "date-time",
"type" : "string"
},
"status" : {
"description" : "The todo state",
"enum" : [ "waiting", "working", "done" ],
"type" : "string"
}
},
"required" : [ "create_date", "id", "status", "title" ],
"type" : "object",
"xml" : {
"name" : "Todo"
}
},
"createTodo_request" : {
"properties" : {
"title" : {
"description" : "The todo title",
"type" : "string"
}
},
"required" : [ "title" ],
"type" : "object"
},
"updateTodo_request" : {
"properties" : {
"title" : {
"description" : "The todo title",
"type" : "string"
},
"status" : {
"description" : "The todo status",
"enum" : [ "working", "waiting", "done" ],
"type" : "string"
}
},
"type" : "object"
}
},
"securitySchemes" : {
"todo_auth" : {
"flows" : {
"password" : {
"scopes" : {
"write:todo" : "Write a todo",
"read:todo" : "Read a todo"
},
"tokenUrl" : "http://localhost:8080/v1/oauth/token"
}
},
"type" : "oauth2"
}
}
}
}