swagger.yml 5.04 KB
Newer Older
Michal Pavlík's avatar
Michal Pavlík committed
1 2 3 4 5 6 7 8 9 10 11
openapi: 3.0.2

info:
  version: 1.0.0
  title: 'Chytro'
  description: 'Aplikácia pre nástenku'

servers:
  - url: 'http://localhost:8080/'
  - url: 'https://localhost:8080/'

Michal Pavlík's avatar
Michal Pavlík committed
12 13 14 15 16
security:
  - BasicAuth: []
  - OAuth2:
    - read
    - write
Michal Pavlík's avatar
Michal Pavlík committed
17 18 19 20 21 22 23

paths:

  /user/avatar:
    put:
      description: 'Upload an user image as avatar.'
      operationId: users.upload_avatar
Michal Pavlík's avatar
Michal Pavlík committed
24
      tags:
Michal Pavlík's avatar
Michal Pavlík committed
25
        - Users
Michal Pavlík's avatar
Michal Pavlík committed
26

Michal Pavlík's avatar
Michal Pavlík committed
27 28
      requestBody:
        content:
Michal Pavlík's avatar
Michal Pavlík committed
29
          multipart/form-data:
Michal Pavlík's avatar
Michal Pavlík committed
30
            schema:
Michal Pavlík's avatar
Michal Pavlík committed
31 32 33 34 35
              type: object
              properties:
                avatar:
                  type: string
                  format: binary
Michal Pavlík's avatar
Michal Pavlík committed
36 37 38 39 40 41 42 43 44 45 46 47 48
      responses:
        200:
          description: 'Image uploaded successfully'
        413:
          description: 'Payload too large'

  /user:
    post:
      description: 'Regsiter a new user'
      operationId: users.register
      tags:
        - Users

Michal Pavlík's avatar
Michal Pavlík committed
49 50
      security: []

Michal Pavlík's avatar
Michal Pavlík committed
51 52 53 54 55 56
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RegisterUser'
Michal Pavlík's avatar
Michal Pavlík committed
57

Michal Pavlík's avatar
Michal Pavlík committed
58 59 60 61 62 63 64 65 66 67 68 69 70 71
      responses:
        201:
          description: 'Register a new user.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
        422:
          description: 'Unprocessable entity'

  /user/{id}:
    get:
      description: 'Get a single user from the database by his ID.'
      operationId: users.get
Michal Pavlík's avatar
Michal Pavlík committed
72
      tags:
Michal Pavlík's avatar
Michal Pavlík committed
73
        - Users
Michal Pavlík's avatar
Michal Pavlík committed
74 75

      parameters:
Michal Pavlík's avatar
Michal Pavlík committed
76
        - $ref: '#/components/parameters/id'
Michal Pavlík's avatar
Michal Pavlík committed
77

Michal Pavlík's avatar
Michal Pavlík committed
78 79 80 81 82 83 84 85 86
      responses:
        200:
          description: 'Correctly found a user by ID'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
        404:
          description: "User with this ID doesn't exist"
Michal Pavlík's avatar
Michal Pavlík committed
87

Michal Pavlík's avatar
Michal Pavlík committed
88 89 90 91

  /post/{id}:
    get:
      description: 'Get post detail'
Michal Pavlík's avatar
Michal Pavlík committed
92

Michal Pavlík's avatar
Michal Pavlík committed
93 94 95
      operationId: posts.get
      tags:
        - Posts
Michal Pavlík's avatar
Michal Pavlík committed
96 97

      parameters:
Michal Pavlík's avatar
Michal Pavlík committed
98
        - $ref: '#/components/parameters/id'
Michal Pavlík's avatar
Michal Pavlík committed
99

Michal Pavlík's avatar
Michal Pavlík committed
100 101 102 103 104
      responses:
        200:
          $ref: '#/components/responses/PostDetail'
        404:
          description: 'Post not found'
Michal Pavlík's avatar
Michal Pavlík committed
105

Michal Pavlík's avatar
Michal Pavlík committed
106 107
    delete:
      description: 'Remove Posts'
Michal Pavlík's avatar
Michal Pavlík committed
108

Michal Pavlík's avatar
Michal Pavlík committed
109 110 111
      operationId: posts.delete
      tags:
        - Posts
Michal Pavlík's avatar
Michal Pavlík committed
112

Michal Pavlík's avatar
Michal Pavlík committed
113 114
      parameters:
        - $ref: '#/components/parameters/id'
Michal Pavlík's avatar
Michal Pavlík committed
115

Michal Pavlík's avatar
Michal Pavlík committed
116 117 118 119 120
      responses:
        204:
          description: 'Success'
        404:
          description: 'Post not found'
Michal Pavlík's avatar
Michal Pavlík committed
121

Michal Pavlík's avatar
Michal Pavlík committed
122 123 124 125 126 127
  /board:
    get:
      description: 'Get all posts paged'
      operationId: boards.all
      tags:
        - Boards
Michal Pavlík's avatar
Michal Pavlík committed
128

Michal Pavlík's avatar
Michal Pavlík committed
129
      security: []
Michal Pavlík's avatar
Michal Pavlík committed
130 131

      parameters:
Michal Pavlík's avatar
Michal Pavlík committed
132 133
        - $ref: '#/components/parameters/PageNumber'
        - $ref: '#/components/parameters/PageSize'
Michal Pavlík's avatar
Michal Pavlík committed
134

Michal Pavlík's avatar
Michal Pavlík committed
135 136 137 138 139 140 141
      responses:
        200:
          description: 'Paged responses here...'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostPage'
Michal Pavlík's avatar
Michal Pavlík committed
142

Michal Pavlík's avatar
Michal Pavlík committed
143 144 145 146 147
    post:
      description: 'Post a new Post'
      operationId: boards.post
      tags:
        - Boards
Michal Pavlík's avatar
Michal Pavlík committed
148

Michal Pavlík's avatar
Michal Pavlík committed
149 150 151 152 153 154 155 156 157
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                message:
                  type: string
Michal Pavlík's avatar
Michal Pavlík committed
158 159 160



Michal Pavlík's avatar
Michal Pavlík committed
161 162 163 164 165 166 167
      responses:
        201:
          $ref: '#/components/responses/PostDetail'
        400:
          description: 'Bad Request'
        422:
          description: 'Unprocessable Entity'
Michal Pavlík's avatar
Michal Pavlík committed
168 169


Michal Pavlík's avatar
Michal Pavlík committed
170 171 172 173 174 175

components:
  securitySchemes:
    BasicAuth:
      type: http
      scheme: basic
Michal Pavlík's avatar
Michal Pavlík committed
176 177
      x-basicInfoFunc: auth.basic_auth

Michal Pavlík's avatar
Michal Pavlík committed
178
    OAuth2:
Michal Pavlík's avatar
Michal Pavlík committed
179
      x-tokenInfoFunc: auth.oauth2
Michal Pavlík's avatar
Michal Pavlík committed
180 181 182
      type: oauth2
      flows:
        password:
Michal Pavlík's avatar
Michal Pavlík committed
183
          tokenUrl: 'http://192.168.0.2:9998/auth/realms/lh-temp/protocol/openid-connect/token'
Michal Pavlík's avatar
Michal Pavlík committed
184 185 186
          scopes:
            read: Grants read
            write: Grants write
Michal Pavlík's avatar
Michal Pavlík committed
187

Michal Pavlík's avatar
Michal Pavlík committed
188 189 190 191 192 193 194 195 196 197 198 199

  schemas:
    Post:
      type: object
      properties:
        message:
          type: string
        author:
          type: string
        created:
          type: string
          format: date-time
Michal Pavlík's avatar
Michal Pavlík committed
200

Michal Pavlík's avatar
Michal Pavlík committed
201 202 203 204 205 206 207
    RegisterUser:
      type: object
      properties:
        username:
          type: string
        password:
          type: string
Michal Pavlík's avatar
Michal Pavlík committed
208

Michal Pavlík's avatar
Michal Pavlík committed
209 210 211 212 213 214 215 216 217 218
    User:
      type: object
      properties:
        username:
          type: string
        created:
          type: string
          format: date-time
        avatarUrl:
          type: string
Michal Pavlík's avatar
Michal Pavlík committed
219

Michal Pavlík's avatar
Michal Pavlík committed
220 221 222 223 224 225 226 227 228 229 230 231 232
    PostPage:
      type: object
      properties:
        content:
          type: array
          items:
            $ref: '#/components/schemas/Post'
        page:
          type: integer
        size:
          type: integer
        totalPages:
          type: integer
Michal Pavlík's avatar
Michal Pavlík committed
233

Michal Pavlík's avatar
Michal Pavlík committed
234 235 236 237 238 239 240
  parameters:
    id:
      name: id
      in: path
      required: true
      schema:
        type: integer
Michal Pavlík's avatar
Michal Pavlík committed
241

Michal Pavlík's avatar
Michal Pavlík committed
242 243 244 245 246 247
    PageNumber:
      name: page
      in: query
      required: false
      schema:
        type: integer
Michal Pavlík's avatar
Michal Pavlík committed
248

Michal Pavlík's avatar
Michal Pavlík committed
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263
    PageSize:
      name: size
      in: query
      required: false
      schema:
        type: integer


  responses:
    PostDetail:
      description: 'Returns a complete detail of a Post object.'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Post'
Michal Pavlík's avatar
Michal Pavlík committed
264 265 266