File: 0001-disable-swagger.patch

package info (click to toggle)
aptly 1.6.1%2Bds1-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 49,932 kB
  • sloc: python: 10,333; sh: 248; makefile: 176
file content (121 lines) | stat: -rw-r--r-- 3,763 bytes parent folder | download
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
From: =?utf-8?q?Andr=C3=A9_Roth?= <neolynx@gmail.com>
Date: Tue, 15 Oct 2024 12:09:33 +0200
Subject: Disable swagger

This can be enabled once the following modules make it into Debian:

  - github.com/swaggo/files v1.0.1
  - github.com/swaggo/gin-swagger v1.6.0
  - github.com/swaggo/swag v1.16.3
---
 api/router.go          | 22 +++++++++++-----------
 docs/index.go          | 10 ----------
 docs/index.go.disabled | 10 ++++++++++
 man/aptly.1            |  3 ++-
 man/aptly.1.ronn.tmpl  |  3 ++-
 5 files changed, 25 insertions(+), 23 deletions(-)
 delete mode 100644 docs/index.go
 create mode 100644 docs/index.go.disabled

diff --git a/api/router.go b/api/router.go
index 3536ab0..7dbf16e 100644
--- a/api/router.go
+++ b/api/router.go
@@ -12,9 +12,9 @@
 	"github.com/prometheus/client_golang/prometheus/promhttp"
 	"github.com/rs/zerolog/log"
 
-	"github.com/aptly-dev/aptly/docs"
-	swaggerFiles "github.com/swaggo/files"
-	ginSwagger "github.com/swaggo/gin-swagger"
+	// _ "github.com/aptly-dev/aptly/docs" // import docs
+	// swaggerFiles "github.com/swaggo/files"
+	// ginSwagger "github.com/swaggo/gin-swagger"
 )
 
 var context *ctx.AptlyContext
@@ -68,14 +68,14 @@ func Router(c *ctx.AptlyContext) http.Handler {
 
 	router.Use(gin.Recovery(), gin.ErrorLogger())
 
-	if c.Config().EnableSwaggerEndpoint {
-		router.GET("docs.html", func(c *gin.Context) {
-			c.Data(http.StatusOK, "text/html; charset=utf-8", docs.DocsHTML)
-		})
-		router.Use(redirectSwagger)
-		url := ginSwagger.URL("/docs/doc.json")
-		router.GET("/docs/*any", ginSwagger.WrapHandler(swaggerFiles.Handler, url))
-	}
+	// if c.Config().EnableSwaggerEndpoint {
+	// 	router.GET("docs.html", func(c *gin.Context) {
+	// 		c.Data(http.StatusOK, "text/html; charset=utf-8", docs.DocsHTML)
+	// 	})
+	// 	router.Use(redirectSwagger)
+	// 	url := ginSwagger.URL("/docs/doc.json")
+	// 	router.GET("/docs/*any", ginSwagger.WrapHandler(swaggerFiles.Handler, url))
+	// }
 
 	if c.Config().EnableMetricsEndpoint {
 		MetricsCollectorRegistrar.Register(router)
diff --git a/docs/index.go b/docs/index.go
deleted file mode 100644
index ca4c914..0000000
--- a/docs/index.go
+++ /dev/null
@@ -1,10 +0,0 @@
-package docs
-
-import (
-	_ "embed" // embed html below
-
-	_ "github.com/swaggo/swag" // make sure swag is in go.mod
-)
-
-//go:embed docs.html
-var DocsHTML []byte
diff --git a/docs/index.go.disabled b/docs/index.go.disabled
new file mode 100644
index 0000000..ca4c914
--- /dev/null
+++ b/docs/index.go.disabled
@@ -0,0 +1,10 @@
+package docs
+
+import (
+	_ "embed" // embed html below
+
+	_ "github.com/swaggo/swag" // make sure swag is in go.mod
+)
+
+//go:embed docs.html
+var DocsHTML []byte
diff --git a/man/aptly.1 b/man/aptly.1
index bd6ad22..11ed990 100644
--- a/man/aptly.1
+++ b/man/aptly.1
@@ -111,8 +111,9 @@ The legacy json configuration is still supported (and also supports comments):
   // Enable metrics for Prometheus client
   "enableMetricsEndpoint": false,
 
+  // Not implemented in this version\.
   // Enable API documentation on /docs
-  "enableSwaggerEndpoint": false,
+  //"enableSwaggerEndpoint": false,
 
   // OBSOLETE: use via url param ?_async=true
   "AsyncAPI": false,
diff --git a/man/aptly.1.ronn.tmpl b/man/aptly.1.ronn.tmpl
index 203cc7f..ed2c87c 100644
--- a/man/aptly.1.ronn.tmpl
+++ b/man/aptly.1.ronn.tmpl
@@ -100,8 +100,9 @@ The legacy json configuration is still supported (and also supports comments):
       // Enable metrics for Prometheus client
       "enableMetricsEndpoint": false,
 
+      // Not implemented in this version.
       // Enable API documentation on /docs
-      "enableSwaggerEndpoint": false,
+      //"enableSwaggerEndpoint": false,
 
       // OBSOLETE: use via url param ?_async=true
       "AsyncAPI": false,