Commit 6fc16d0b1cf5f145c313d78241ba56835f392433

Authored by Georg Hopp
1 parent dd08954d

First steps on API documentation

... ... @@ -52,6 +52,7 @@ async fn main() -> std::io::Result<()> {
52 52 )
53 53 . service( web::scope("")
54 54 . route("/", web::get().to(root))
  55 + . route("/api.html", web::get().to(apidoc))
55 56 . route("/index", web::get().to(root))
56 57 . route("/index.html", web::get().to(root))
57 58 . route("/favicon", web::get().to(favicon))
... ...
... ... @@ -5,6 +5,10 @@ pub async fn root() -> Result<actix_files::NamedFile, Error> {
5 5 Ok(actix_files::NamedFile::open("static/index.html")?)
6 6 }
7 7
  8 +pub async fn apidoc() -> Result<actix_files::NamedFile, Error> {
  9 + Ok(actix_files::NamedFile::open("static/api.html")?)
  10 +}
  11 +
8 12 pub async fn p404() -> Result<actix_files::NamedFile, Error> {
9 13 Ok(actix_files::NamedFile::open("static/404.html")?)
10 14 }
... ...
  1 +<!doctype html>
  2 +<html lang="en">
  3 + <head>
  4 + <meta charset="utf-8">
  5 + <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  6 + <title>Elements in HTML</title>
  7 + <!-- Embed elements Elements via Web Component -->
  8 + <script src="https://unpkg.com/@stoplight/elements/web-components.min.js"></script>
  9 + <link rel="stylesheet" href="https://unpkg.com/@stoplight/elements/styles.min.css">
  10 + </head>
  11 + <body>
  12 +
  13 + <elements-api
  14 + apiDescriptionUrl="/static/openapi.yaml"
  15 + router="hash"
  16 + layout="sidebar"
  17 + />
  18 +
  19 + </body>
  20 +</html>
... ...
  1 +openapi: 3.0.0
  2 +info:
  3 + version: 0.0.1
  4 + title: Artshop API
  5 + description: A first simple try do document out api
  6 +paths:
  7 + /api/v0/markdowns:
  8 + get:
  9 + description: Returns a list of all available markdown documents.
  10 + responses:
  11 + '200':
  12 + description: Successful response
... ...
Please register or login to post a comment