Skip to content

Commit a1a7581

Browse files
committed
Testing Swagger generation
1 parent e31c02d commit a1a7581

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed

routers/api/v1/api.go

+23
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,29 @@
22
// Use of this source code is governed by a MIT-style
33
// license that can be found in the LICENSE file.
44

5+
//go:generate swagger generate spec
6+
7+
// Package v1 Gitea API.
8+
//
9+
// This provide API interface to communicate with this Gitea instance.
10+
//
11+
// Terms Of Service:
12+
//
13+
// there are no TOS at this moment, use at your own risk we take no responsibility
14+
//
15+
// Schemes: http, https
16+
// BasePath: /api/v1
17+
// Version: 1.1.1
18+
// License: MIT http://opensource.org/licenses/MIT
19+
//
20+
// Consumes:
21+
// - application/json
22+
//
23+
// Produces:
24+
// - application/json
25+
//
26+
//
27+
// swagger:meta
528
package v1
629

730
import (

routers/api/v1/misc/markdown.go

+35
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,24 @@ import (
1515
// Markdown render markdown document to HTML
1616
// see https://github.com/gogits/go-gogs-client/wiki/Miscellaneous#render-an-arbitrary-markdown-document
1717
func Markdown(ctx *context.APIContext, form api.MarkdownOption) {
18+
// swagger:route GET /markdown renderMarkdown
19+
//
20+
// TODO title
21+
//
22+
// TODO desc
23+
//
24+
// Consumes:
25+
// - application/json
26+
//
27+
// Produces:
28+
// - text/html
29+
//
30+
// Schemes: http, https
31+
//
32+
// Responses:
33+
// 200: markdownRender
34+
// 422: validationError
35+
1836
if ctx.HasAPIError() {
1937
ctx.Error(422, "", ctx.GetErrMsg())
2038
return
@@ -42,6 +60,23 @@ func Markdown(ctx *context.APIContext, form api.MarkdownOption) {
4260
// MarkdownRaw render raw markdown HTML
4361
// see https://github.com/gogits/go-gogs-client/wiki/Miscellaneous#render-a-markdown-document-in-raw-mode
4462
func MarkdownRaw(ctx *context.APIContext) {
63+
// swagger:route GET /markdown/raw renderMarkdownRaw
64+
//
65+
// TODO title
66+
//
67+
// TODO desc
68+
//
69+
// Consumes:
70+
// - text/plain
71+
//
72+
// Produces:
73+
// - text/html
74+
//
75+
// Schemes: http, https
76+
//
77+
// Responses:
78+
// 200: markdownRawRender
79+
// 422: validationError
4580
body, err := ctx.Req.Body().Bytes()
4681
if err != nil {
4782
ctx.Error(422, "", err)

routers/api/v1/misc/version.go

+14
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,19 @@ import (
1212

1313
// Version shows the version of the Gitea server
1414
func Version(ctx *context.APIContext) {
15+
16+
// swagger:route GET /version getVersion
17+
//
18+
// Return Gitea running version.
19+
//
20+
// This show current running Gitea application version.
21+
//
22+
// Produces:
23+
// - application/json
24+
//
25+
// Schemes: http, https
26+
//
27+
// Responses:
28+
// 200: serverVersion
1529
ctx.JSON(200, &gitea.ServerVersion{Version: setting.AppVer})
1630
}

0 commit comments

Comments
 (0)