aboutsummaryrefslogtreecommitdiffhomepage
path: root/typespec/fortee/main.tsp
blob: 03683a7978272fac7a9a3de25e3f3036f2a3c2e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import "@typespec/http";
import "@typespec/openapi";
import "@typespec/openapi3";

using TypeSpec.Http;
using TypeSpec.OpenAPI;

@service(#{
  title: "fortee API",
})
@info(#{
  version: "0.1.0",
})
namespace ForteeApi;

@route("/api/user/login")
@post
@operationId("postLogin")
op postLogin(
  @header contentType: "application/x-www-form-urlencoded",
  @body body: {
    username: string;
    password: string;
  },
): {
  @body body: {
    loggedIn: boolean;
    user?: {
      username: string;
    };
  };
};

@route("/api/user/view/{username}")
@get
@operationId("getUser")
op getUser(@path username: string): {
  @body body: {
    uuid: string;
    username: string;
    avatar_url: string;
  };
} | {
  @statusCode statusCode: 404;
};