Skip to content

Commit

Permalink
fix: 2024-03-08 11:25:16
Browse files Browse the repository at this point in the history
  • Loading branch information
kooksee committed Mar 8, 2024
1 parent a269e36 commit 57187ea
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 19 deletions.
13 changes: 6 additions & 7 deletions internal/examples/main.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package main

import (
"os"

"github.com/pubgo/funk/assert"
"github.com/pubgo/funk/recovery"
"github.com/pubgo/opendoc/opendoc"
"github.com/pubgo/opendoc/security"
"net/http"
)

type TestQueryReqAAA struct {
Expand Down Expand Up @@ -64,10 +63,10 @@ func main() {
})
})

data := assert.Must1(doc.MarshalYAML())
assert.Exit(os.WriteFile("openapi.yaml", data, 0644))
//data := assert.Must1(doc.MarshalYAML())
//assert.Exit(os.WriteFile("openapi.yaml", data, 0644))

//var app = fiber.New()
//doc.InitRouter(app)
//assert.Exit(app.Listen("localhost:8080"))
var app = http.NewServeMux()
doc.InitRouter(app)
assert.Exit(http.ListenAndServe("localhost:8080", app))
}
20 changes: 20 additions & 0 deletions internal/examples/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,26 @@ paths:
- req
type: object
description: OK
Test:
content:
application/json:
schema:
properties:
name:
default: test
description: name of model validate:required
nullable: true
type: string
name1:
default: test
description: name1 of model validate:required
nullable: true
type: string
required:
- name
- name1
type: object
description: Test
default:
content:
application/json:
Expand Down
26 changes: 14 additions & 12 deletions templates/swagger.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,24 @@
<head>
<meta charset="utf-8">
<title>{{ .title }} - Swagger UI</title>
<link rel="stylesheet" type="text/css" href="https://unpkg.com/swagger-ui-dist@3/swagger-ui.css">
<script src="https://unpkg.com/swagger-ui-dist@3/swagger-ui-bundle.js" charset="UTF-8"></script>
<link rel="stylesheet" type="text/css" href="//unpkg.com/[email protected]/swagger-ui.css">
<link rel="icon" type="image/png" href="//unpkg.com/[email protected]/favicon-16x16.png"/>
<script src="//unpkg.com/[email protected]/swagger-ui-bundle.js"></script>
</head>
<body>
<div id="openapi"></div>
<script>
let options = JSON.parse('{{ .openapi_options }}')
SwaggerUIBundle({
url: "{{ .openapi_url }}",
dom_id: '#openapi',
presets: [
SwaggerUIBundle.presets.apis,
],
persistAuthorization: true,
...options
})
window.onload = function () {
let options = JSON.parse('{{ .openapi_options }}')
window.ui = SwaggerUIBundle({
deepLinking: true,
layout: "BaseLayout",
url: "{{ .openapi_url }}",
dom_id: '#openapi',
persistAuthorization: true,
...options
});
}
</script>
</body>
</html>

0 comments on commit 57187ea

Please sign in to comment.