-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.gen.go
710 lines (607 loc) · 27.1 KB
/
server.gen.go
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
// Package openapi provides primitives to interact with the openapi HTTP API.
//
// Code generated by github.com/deepmap/oapi-codegen/v2 version v2.0.0 DO NOT EDIT.
package openapi
import (
"bytes"
"compress/gzip"
"encoding/base64"
"fmt"
"net/http"
"net/url"
"path"
"strings"
"github.com/getkin/kin-openapi/openapi3"
"github.com/labstack/echo/v4"
"github.com/oapi-codegen/runtime"
. "github.com/traPtitech/game3-back/openapi/models"
)
// ServerInterface represents all server handlers.
type ServerInterface interface {
// OAuth認証コールバック
// (GET /auth/callback)
OauthCallback(ctx echo.Context, params OauthCallbackParams) error
// ログイン
// (POST /auth/login)
Login(ctx echo.Context) error
// ログアウト
// (POST /auth/logout)
Logout(ctx echo.Context) error
// イベントのリストを取得
// (GET /events)
GetEvents(ctx echo.Context) error
// イベントを登録
// (POST /events)
PostEvent(ctx echo.Context) error
// 開催中のイベントを取得
// (GET /events/now)
GetCurrentEvent(ctx echo.Context) error
// イベントの情報を取得
// (GET /events/{eventSlug})
GetEvent(ctx echo.Context, eventSlug EventSlugInPath) error
// イベントの情報を変更
// (PATCH /events/{eventSlug})
PatchEvent(ctx echo.Context, eventSlug EventSlugInPath) error
// イベントとイベントに登録されているゲームの情報をCSV形式で取得
// (GET /events/{eventSlug}/csv)
GetEventCsv(ctx echo.Context, eventSlug EventSlugInPath) error
// イベントに登録されているゲームのリストを取得
// (GET /events/{eventSlug}/games)
GetEventGames(ctx echo.Context, eventSlug EventSlugInPath) error
// イベントの画像を取得
// (GET /events/{eventSlug}/image)
GetEventImage(ctx echo.Context, eventSlug EventSlugInPath) error
// イベントに登録されているタームのリストを取得
// (GET /events/{eventSlug}/terms)
GetEventTerms(ctx echo.Context, eventSlug EventSlugInPath) error
// ゲームのリストを取得 GET /games?termId=X&eventSlug=X&userId=X&include=unpublished
// (GET /games)
GetGames(ctx echo.Context, params GetGamesParams) error
// ゲームを登録
// (POST /games)
PostGame(ctx echo.Context) error
// ゲーム情報を取得
// (GET /games/{gameId})
GetGame(ctx echo.Context, gameId GameIdInPath) error
// ゲーム情報を変更
// (PATCH /games/{gameId})
PatchGame(ctx echo.Context, gameId GameIdInPath) error
// ゲームのアイコン画像を取得
// (GET /games/{gameId}/icon)
GetGameIcon(ctx echo.Context, gameId GameIdInPath) error
// ゲームの画像を取得
// (GET /games/{gameId}/image)
GetGameImage(ctx echo.Context, gameId GameIdInPath) error
// サーバーの生存確認
// (GET /ping)
PingServer(ctx echo.Context) error
// イベントに登録されているタームのリストを取得
// (GET /terms)
GetTerms(ctx echo.Context) error
// タームを登録
// (POST /terms)
PostTerm(ctx echo.Context) error
// ターム情報を取得
// (GET /terms/{termId})
GetTerm(ctx echo.Context, termId TermIdInPath) error
// ターム情報を変更
// (PATCH /terms/{termId})
PatchTerm(ctx echo.Context, termId TermIdInPath) error
// タームに登録されているゲームのリストを取得
// (GET /terms/{termId}/games)
GetTermGames(ctx echo.Context, termId TermIdInPath) error
// テスト用
// (GET /test)
Test(ctx echo.Context) error
// 自分のユーザー情報を取得
// (GET /users/me)
GetMe(ctx echo.Context) error
// 自分が登録したゲームのリストを取得
// (GET /users/me/games)
GetMeGames(ctx echo.Context) error
// ユーザー情報を取得
// (GET /users/{userId})
GetUser(ctx echo.Context, userId UserIdInPath) error
// ユーザーが登録したゲームのリストを取得
// (GET /users/{userId}/games)
GetUserGames(ctx echo.Context, userId UserIdInPath) error
}
// ServerInterfaceWrapper converts echo contexts to parameters.
type ServerInterfaceWrapper struct {
Handler ServerInterface
}
// OauthCallback converts echo context to params.
func (w *ServerInterfaceWrapper) OauthCallback(ctx echo.Context) error {
var err error
// Parameter object where we will unmarshal all parameters from the context
var params OauthCallbackParams
// ------------- Required query parameter "code" -------------
err = runtime.BindQueryParameter("form", true, true, "code", ctx.QueryParams(), ¶ms.Code)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter code: %s", err))
}
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.OauthCallback(ctx, params)
return err
}
// Login converts echo context to params.
func (w *ServerInterfaceWrapper) Login(ctx echo.Context) error {
var err error
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.Login(ctx)
return err
}
// Logout converts echo context to params.
func (w *ServerInterfaceWrapper) Logout(ctx echo.Context) error {
var err error
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.Logout(ctx)
return err
}
// GetEvents converts echo context to params.
func (w *ServerInterfaceWrapper) GetEvents(ctx echo.Context) error {
var err error
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.GetEvents(ctx)
return err
}
// PostEvent converts echo context to params.
func (w *ServerInterfaceWrapper) PostEvent(ctx echo.Context) error {
var err error
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.PostEvent(ctx)
return err
}
// GetCurrentEvent converts echo context to params.
func (w *ServerInterfaceWrapper) GetCurrentEvent(ctx echo.Context) error {
var err error
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.GetCurrentEvent(ctx)
return err
}
// GetEvent converts echo context to params.
func (w *ServerInterfaceWrapper) GetEvent(ctx echo.Context) error {
var err error
// ------------- Path parameter "eventSlug" -------------
var eventSlug EventSlugInPath
err = runtime.BindStyledParameterWithLocation("simple", false, "eventSlug", runtime.ParamLocationPath, ctx.Param("eventSlug"), &eventSlug)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter eventSlug: %s", err))
}
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.GetEvent(ctx, eventSlug)
return err
}
// PatchEvent converts echo context to params.
func (w *ServerInterfaceWrapper) PatchEvent(ctx echo.Context) error {
var err error
// ------------- Path parameter "eventSlug" -------------
var eventSlug EventSlugInPath
err = runtime.BindStyledParameterWithLocation("simple", false, "eventSlug", runtime.ParamLocationPath, ctx.Param("eventSlug"), &eventSlug)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter eventSlug: %s", err))
}
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.PatchEvent(ctx, eventSlug)
return err
}
// GetEventCsv converts echo context to params.
func (w *ServerInterfaceWrapper) GetEventCsv(ctx echo.Context) error {
var err error
// ------------- Path parameter "eventSlug" -------------
var eventSlug EventSlugInPath
err = runtime.BindStyledParameterWithLocation("simple", false, "eventSlug", runtime.ParamLocationPath, ctx.Param("eventSlug"), &eventSlug)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter eventSlug: %s", err))
}
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.GetEventCsv(ctx, eventSlug)
return err
}
// GetEventGames converts echo context to params.
func (w *ServerInterfaceWrapper) GetEventGames(ctx echo.Context) error {
var err error
// ------------- Path parameter "eventSlug" -------------
var eventSlug EventSlugInPath
err = runtime.BindStyledParameterWithLocation("simple", false, "eventSlug", runtime.ParamLocationPath, ctx.Param("eventSlug"), &eventSlug)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter eventSlug: %s", err))
}
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.GetEventGames(ctx, eventSlug)
return err
}
// GetEventImage converts echo context to params.
func (w *ServerInterfaceWrapper) GetEventImage(ctx echo.Context) error {
var err error
// ------------- Path parameter "eventSlug" -------------
var eventSlug EventSlugInPath
err = runtime.BindStyledParameterWithLocation("simple", false, "eventSlug", runtime.ParamLocationPath, ctx.Param("eventSlug"), &eventSlug)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter eventSlug: %s", err))
}
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.GetEventImage(ctx, eventSlug)
return err
}
// GetEventTerms converts echo context to params.
func (w *ServerInterfaceWrapper) GetEventTerms(ctx echo.Context) error {
var err error
// ------------- Path parameter "eventSlug" -------------
var eventSlug EventSlugInPath
err = runtime.BindStyledParameterWithLocation("simple", false, "eventSlug", runtime.ParamLocationPath, ctx.Param("eventSlug"), &eventSlug)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter eventSlug: %s", err))
}
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.GetEventTerms(ctx, eventSlug)
return err
}
// GetGames converts echo context to params.
func (w *ServerInterfaceWrapper) GetGames(ctx echo.Context) error {
var err error
// Parameter object where we will unmarshal all parameters from the context
var params GetGamesParams
// ------------- Optional query parameter "termId" -------------
err = runtime.BindQueryParameter("form", true, false, "termId", ctx.QueryParams(), ¶ms.TermId)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter termId: %s", err))
}
// ------------- Optional query parameter "eventSlug" -------------
err = runtime.BindQueryParameter("form", true, false, "eventSlug", ctx.QueryParams(), ¶ms.EventSlug)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter eventSlug: %s", err))
}
// ------------- Optional query parameter "userId" -------------
err = runtime.BindQueryParameter("form", true, false, "userId", ctx.QueryParams(), ¶ms.UserId)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter userId: %s", err))
}
// ------------- Optional query parameter "include" -------------
err = runtime.BindQueryParameter("form", true, false, "include", ctx.QueryParams(), ¶ms.Include)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter include: %s", err))
}
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.GetGames(ctx, params)
return err
}
// PostGame converts echo context to params.
func (w *ServerInterfaceWrapper) PostGame(ctx echo.Context) error {
var err error
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.PostGame(ctx)
return err
}
// GetGame converts echo context to params.
func (w *ServerInterfaceWrapper) GetGame(ctx echo.Context) error {
var err error
// ------------- Path parameter "gameId" -------------
var gameId GameIdInPath
err = runtime.BindStyledParameterWithLocation("simple", false, "gameId", runtime.ParamLocationPath, ctx.Param("gameId"), &gameId)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter gameId: %s", err))
}
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.GetGame(ctx, gameId)
return err
}
// PatchGame converts echo context to params.
func (w *ServerInterfaceWrapper) PatchGame(ctx echo.Context) error {
var err error
// ------------- Path parameter "gameId" -------------
var gameId GameIdInPath
err = runtime.BindStyledParameterWithLocation("simple", false, "gameId", runtime.ParamLocationPath, ctx.Param("gameId"), &gameId)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter gameId: %s", err))
}
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.PatchGame(ctx, gameId)
return err
}
// GetGameIcon converts echo context to params.
func (w *ServerInterfaceWrapper) GetGameIcon(ctx echo.Context) error {
var err error
// ------------- Path parameter "gameId" -------------
var gameId GameIdInPath
err = runtime.BindStyledParameterWithLocation("simple", false, "gameId", runtime.ParamLocationPath, ctx.Param("gameId"), &gameId)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter gameId: %s", err))
}
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.GetGameIcon(ctx, gameId)
return err
}
// GetGameImage converts echo context to params.
func (w *ServerInterfaceWrapper) GetGameImage(ctx echo.Context) error {
var err error
// ------------- Path parameter "gameId" -------------
var gameId GameIdInPath
err = runtime.BindStyledParameterWithLocation("simple", false, "gameId", runtime.ParamLocationPath, ctx.Param("gameId"), &gameId)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter gameId: %s", err))
}
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.GetGameImage(ctx, gameId)
return err
}
// PingServer converts echo context to params.
func (w *ServerInterfaceWrapper) PingServer(ctx echo.Context) error {
var err error
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.PingServer(ctx)
return err
}
// GetTerms converts echo context to params.
func (w *ServerInterfaceWrapper) GetTerms(ctx echo.Context) error {
var err error
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.GetTerms(ctx)
return err
}
// PostTerm converts echo context to params.
func (w *ServerInterfaceWrapper) PostTerm(ctx echo.Context) error {
var err error
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.PostTerm(ctx)
return err
}
// GetTerm converts echo context to params.
func (w *ServerInterfaceWrapper) GetTerm(ctx echo.Context) error {
var err error
// ------------- Path parameter "termId" -------------
var termId TermIdInPath
err = runtime.BindStyledParameterWithLocation("simple", false, "termId", runtime.ParamLocationPath, ctx.Param("termId"), &termId)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter termId: %s", err))
}
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.GetTerm(ctx, termId)
return err
}
// PatchTerm converts echo context to params.
func (w *ServerInterfaceWrapper) PatchTerm(ctx echo.Context) error {
var err error
// ------------- Path parameter "termId" -------------
var termId TermIdInPath
err = runtime.BindStyledParameterWithLocation("simple", false, "termId", runtime.ParamLocationPath, ctx.Param("termId"), &termId)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter termId: %s", err))
}
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.PatchTerm(ctx, termId)
return err
}
// GetTermGames converts echo context to params.
func (w *ServerInterfaceWrapper) GetTermGames(ctx echo.Context) error {
var err error
// ------------- Path parameter "termId" -------------
var termId TermIdInPath
err = runtime.BindStyledParameterWithLocation("simple", false, "termId", runtime.ParamLocationPath, ctx.Param("termId"), &termId)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter termId: %s", err))
}
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.GetTermGames(ctx, termId)
return err
}
// Test converts echo context to params.
func (w *ServerInterfaceWrapper) Test(ctx echo.Context) error {
var err error
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.Test(ctx)
return err
}
// GetMe converts echo context to params.
func (w *ServerInterfaceWrapper) GetMe(ctx echo.Context) error {
var err error
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.GetMe(ctx)
return err
}
// GetMeGames converts echo context to params.
func (w *ServerInterfaceWrapper) GetMeGames(ctx echo.Context) error {
var err error
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.GetMeGames(ctx)
return err
}
// GetUser converts echo context to params.
func (w *ServerInterfaceWrapper) GetUser(ctx echo.Context) error {
var err error
// ------------- Path parameter "userId" -------------
var userId UserIdInPath
err = runtime.BindStyledParameterWithLocation("simple", false, "userId", runtime.ParamLocationPath, ctx.Param("userId"), &userId)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter userId: %s", err))
}
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.GetUser(ctx, userId)
return err
}
// GetUserGames converts echo context to params.
func (w *ServerInterfaceWrapper) GetUserGames(ctx echo.Context) error {
var err error
// ------------- Path parameter "userId" -------------
var userId UserIdInPath
err = runtime.BindStyledParameterWithLocation("simple", false, "userId", runtime.ParamLocationPath, ctx.Param("userId"), &userId)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter userId: %s", err))
}
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.GetUserGames(ctx, userId)
return err
}
// This is a simple interface which specifies echo.Route addition functions which
// are present on both echo.Echo and echo.Group, since we want to allow using
// either of them for path registration
type EchoRouter interface {
CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
}
// RegisterHandlers adds each server route to the EchoRouter.
func RegisterHandlers(router EchoRouter, si ServerInterface) {
RegisterHandlersWithBaseURL(router, si, "")
}
// Registers handlers, and prepends BaseURL to the paths, so that the paths
// can be served under a prefix.
func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string) {
wrapper := ServerInterfaceWrapper{
Handler: si,
}
router.GET(baseURL+"/auth/callback", wrapper.OauthCallback)
router.POST(baseURL+"/auth/login", wrapper.Login)
router.POST(baseURL+"/auth/logout", wrapper.Logout)
router.GET(baseURL+"/events", wrapper.GetEvents)
router.POST(baseURL+"/events", wrapper.PostEvent)
router.GET(baseURL+"/events/now", wrapper.GetCurrentEvent)
router.GET(baseURL+"/events/:eventSlug", wrapper.GetEvent)
router.PATCH(baseURL+"/events/:eventSlug", wrapper.PatchEvent)
router.GET(baseURL+"/events/:eventSlug/csv", wrapper.GetEventCsv)
router.GET(baseURL+"/events/:eventSlug/games", wrapper.GetEventGames)
router.GET(baseURL+"/events/:eventSlug/image", wrapper.GetEventImage)
router.GET(baseURL+"/events/:eventSlug/terms", wrapper.GetEventTerms)
router.GET(baseURL+"/games", wrapper.GetGames)
router.POST(baseURL+"/games", wrapper.PostGame)
router.GET(baseURL+"/games/:gameId", wrapper.GetGame)
router.PATCH(baseURL+"/games/:gameId", wrapper.PatchGame)
router.GET(baseURL+"/games/:gameId/icon", wrapper.GetGameIcon)
router.GET(baseURL+"/games/:gameId/image", wrapper.GetGameImage)
router.GET(baseURL+"/ping", wrapper.PingServer)
router.GET(baseURL+"/terms", wrapper.GetTerms)
router.POST(baseURL+"/terms", wrapper.PostTerm)
router.GET(baseURL+"/terms/:termId", wrapper.GetTerm)
router.PATCH(baseURL+"/terms/:termId", wrapper.PatchTerm)
router.GET(baseURL+"/terms/:termId/games", wrapper.GetTermGames)
router.GET(baseURL+"/test", wrapper.Test)
router.GET(baseURL+"/users/me", wrapper.GetMe)
router.GET(baseURL+"/users/me/games", wrapper.GetMeGames)
router.GET(baseURL+"/users/:userId", wrapper.GetUser)
router.GET(baseURL+"/users/:userId/games", wrapper.GetUserGames)
}
// Base64 encoded, gzipped, json marshaled Swagger object
var swaggerSpec = []string{
"H4sIAAAAAAAC/+xcfW/bRtL/KgKfB2gLyJYSF4dAQHFonTYwLm0NOy4O6PmMtbiR2EokQy5zyRkCTLJ2",
"ncq5pG6S1m1wTnNB7LMdJ02au1wSRx9mTcv+FofdJSVSfNWr3Vz+MSJpuTM7M7+Z384uM8flpbIsiVBE",
"Kpeb42SggDJEUKGf4EUoosmSVhgTxwEqkq8EkctxMvmQ5kRQhlyuOYpLcwq8oAkK5LkcUjSY5tR8EZYB",
"eZCHal4RZCRIZAZs3MPmKjafYHPJfhRdlslsKlIEscBVKmmuAMpwjI+UzYa0JfgxNl9i887YaS7NnZeU",
"MkBcjtM0gQ/UAUGlHKMDG9KWDrW2dNBUqMTowIa0o4N5n+hg/AubL6karWIrzrM0Ej4kPqYBokgyVJAA",
"6dfE/JPabFlQVUESx6EiSPyHIh9hduuX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7QWNuiub+fYbjGZdaOpJ11252f9cbzTfXlxwLyTOfRY",
"8s5aOO90fNZAR2aObUYqcTBpO516/jORvvLOMFe4kmktjHe2BZ5aHGF0QSKCMPbKnH3AVOvbTv+rbLEW",
"xxbDgRTfZSMG7ux8oreY6ldbplE/BnEy0YmwKOgyh7J6FujAc+yCapDlvTp/+gffLaNFJr9+Y4MRFE0l",
"Xi1HEtqPYT8vTNCbu5HudPVKu0qfB19vWkuLLW8rh6dSahrbH46Z4qH1MXSA1ZXF/C8Sqt0CJvCCYYjN",
"7UiO7G92YPllByH0ElxSYPgdMccalJGUYYrd324vvXn+76++UobBhX2n0e4YOT7myVo6Kye9tffrBRq3",
"37qGDpmZ7pgDz9PMB1TSFja36iuPrLum542BXCZTkvKgVJRUlDuVPZXNAFnggs6etus3NwMmoK8cgDIc",
"GUYKkIdZQ4XOMd1QNfRNGfZ2geudBpULOqurBYxmFTX6ZM/zgH1m6X+CXXv3jKX3cqNP9jzjmSsq05X/",
"BgAA//9PZIJFBVIAAA==",
}
// GetSwagger returns the content of the embedded swagger specification file
// or error if failed to decode
func decodeSpec() ([]byte, error) {
zipped, err := base64.StdEncoding.DecodeString(strings.Join(swaggerSpec, ""))
if err != nil {
return nil, fmt.Errorf("error base64 decoding spec: %w", err)
}
zr, err := gzip.NewReader(bytes.NewReader(zipped))
if err != nil {
return nil, fmt.Errorf("error decompressing spec: %w", err)
}
var buf bytes.Buffer
_, err = buf.ReadFrom(zr)
if err != nil {
return nil, fmt.Errorf("error decompressing spec: %w", err)
}
return buf.Bytes(), nil
}
var rawSpec = decodeSpecCached()
// a naive cached of a decoded swagger spec
func decodeSpecCached() func() ([]byte, error) {
data, err := decodeSpec()
return func() ([]byte, error) {
return data, err
}
}
// Constructs a synthetic filesystem for resolving external references when loading openapi specifications.
func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error) {
res := make(map[string]func() ([]byte, error))
if len(pathToFile) > 0 {
res[pathToFile] = rawSpec
}
return res
}
// GetSwagger returns the Swagger specification corresponding to the generated code
// in this file. The external references of Swagger specification are resolved.
// The logic of resolving external references is tightly connected to "import-mapping" feature.
// Externally referenced files must be embedded in the corresponding golang packages.
// Urls can be supported but this task was out of the scope.
func GetSwagger() (swagger *openapi3.T, err error) {
resolvePath := PathToRawSpec("")
loader := openapi3.NewLoader()
loader.IsExternalRefsAllowed = true
loader.ReadFromURIFunc = func(loader *openapi3.Loader, url *url.URL) ([]byte, error) {
pathToFile := url.String()
pathToFile = path.Clean(pathToFile)
getSpec, ok := resolvePath[pathToFile]
if !ok {
err1 := fmt.Errorf("path not found: %s", pathToFile)
return nil, err1
}
return getSpec()
}
var specData []byte
specData, err = rawSpec()
if err != nil {
return
}
swagger, err = loader.LoadFromData(specData)
if err != nil {
return
}
return
}