{"openapi":"3.1.0","info":{"title":"Markdown Files API","description":"A REST API for publishing, storing, and retrieving markdown files. Files are stored in a Turso database and can be managed via simple HTTP endpoints.","version":"1.0.0"},"servers":[{"url":"{server_url}","description":"The deployed server","variables":{"server_url":{"default":"http://localhost:3000","description":"Base URL of the API server"}}}],"paths":{"/api/documents":{"get":{"operationId":"listDocuments","summary":"List all markdown documents","description":"Returns a list of all stored markdown documents with their metadata (without content).","responses":{"200":{"description":"A list of documents","content":{"application/json":{"schema":{"type":"object","properties":{"documents":{"type":"array","items":{"$ref":"#/components/schemas/DocumentMeta"}}}}}}}}},"post":{"operationId":"createDocument","summary":"Publish a markdown document","description":"Upload a new markdown document. If a document with the same slug already exists, it will be updated.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name","content"],"properties":{"name":{"type":"string","description":"The display name of the document"},"content":{"type":"string","description":"The full markdown content"},"description":{"type":"string","description":"An optional short description of the document"}}}}}},"responses":{"200":{"description":"Document updated (slug already existed)","content":{"application/json":{"schema":{"type":"object","properties":{"document":{"$ref":"#/components/schemas/Document"}}}}}},"201":{"description":"Document created","content":{"application/json":{"schema":{"type":"object","properties":{"document":{"$ref":"#/components/schemas/Document"}}}}}},"400":{"description":"Missing required fields","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/documents/{slug}":{"get":{"operationId":"getDocument","summary":"Get a document by slug","description":"Returns the full document including its markdown content.","parameters":[{"name":"slug","in":"path","required":true,"schema":{"type":"string"},"description":"The document slug"}],"responses":{"200":{"description":"The document","content":{"application/json":{"schema":{"type":"object","properties":{"document":{"$ref":"#/components/schemas/Document"}}}}}},"404":{"description":"Document not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"operationId":"deleteDocument","summary":"Delete a document","description":"Permanently deletes a document by its slug.","parameters":[{"name":"slug","in":"path","required":true,"schema":{"type":"string"},"description":"The document slug"}],"responses":{"200":{"description":"Document deleted","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}},"404":{"description":"Document not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/documents/{slug}/raw":{"get":{"operationId":"downloadDocument","summary":"Download the raw markdown file","description":"Returns the raw markdown content as a downloadable .md file.","parameters":[{"name":"slug","in":"path","required":true,"schema":{"type":"string"},"description":"The document slug"}],"responses":{"200":{"description":"The raw markdown file","content":{"text/markdown":{"schema":{"type":"string"}}}},"404":{"description":"Document not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"schemas":{"DocumentMeta":{"type":"object","properties":{"id":{"type":"integer"},"name":{"type":"string"},"slug":{"type":"string"},"description":{"type":"string","nullable":true},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}},"Document":{"type":"object","properties":{"id":{"type":"integer"},"name":{"type":"string"},"slug":{"type":"string"},"description":{"type":"string","nullable":true},"content":{"type":"string"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}},"Error":{"type":"object","properties":{"error":{"type":"string"}}}}}}