Skip to content

Commit

Permalink
next-ui: use swagger for API
Browse files Browse the repository at this point in the history
Signed-off-by: Login Victor <batazor@evrone.com>
  • Loading branch information
batazor committed Aug 22, 2022
1 parent 75dbb8a commit 1a9e2ee
Show file tree
Hide file tree
Showing 15 changed files with 524 additions and 485 deletions.
28 changes: 15 additions & 13 deletions docs/api/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,62 +45,64 @@ const docTemplate = `{
}
}
},
"put": {
"description": "Update link",
"post": {
"description": "Add link",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"summary": "Update link",
"operationId": "update-link",
"summary": "Add link",
"operationId": "add-link",
"parameters": [
{
"description": "Link",
"name": "link",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v1.UpdateRequest"
"$ref": "#/definitions/v1.AddRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/v1.UpdateResponse"
"$ref": "#/definitions/v1.AddResponse"
}
}
}
},
"post": {
"description": "Add link",
}
},
"/links/:hash": {
"put": {
"description": "Update link",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"summary": "Add link",
"operationId": "add-link",
"summary": "Update link",
"operationId": "update-link",
"parameters": [
{
"description": "Link",
"name": "link",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v1.AddRequest"
"$ref": "#/definitions/v1.UpdateRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/v1.AddResponse"
"$ref": "#/definitions/v1.UpdateResponse"
}
}
}
Expand Down
28 changes: 15 additions & 13 deletions docs/api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,62 +42,64 @@
}
}
},
"put": {
"description": "Update link",
"post": {
"description": "Add link",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"summary": "Update link",
"operationId": "update-link",
"summary": "Add link",
"operationId": "add-link",
"parameters": [
{
"description": "Link",
"name": "link",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v1.UpdateRequest"
"$ref": "#/definitions/v1.AddRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/v1.UpdateResponse"
"$ref": "#/definitions/v1.AddResponse"
}
}
}
},
"post": {
"description": "Add link",
}
},
"/links/:hash": {
"put": {
"description": "Update link",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"summary": "Add link",
"operationId": "add-link",
"summary": "Update link",
"operationId": "update-link",
"parameters": [
{
"description": "Link",
"name": "link",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v1.AddRequest"
"$ref": "#/definitions/v1.UpdateRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/v1.AddResponse"
"$ref": "#/definitions/v1.UpdateResponse"
}
}
}
Expand Down
1 change: 1 addition & 0 deletions docs/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ paths:
schema:
$ref: '#/definitions/v1.AddResponse'
summary: Add link
/links/:hash:
put:
consumes:
- application/json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (h *Handler) Add(w http.ResponseWriter, r *http.Request) {
// @Produce json
// @Group Links
// @Success 200 {object} link_rpc.UpdateResponse
// @Router /links [put]
// @Router /links/:hash [put]
// @Param link body link_rpc.UpdateRequest true "Link"
func (h *Handler) Update(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Content-type", "application/json")
Expand Down
8 changes: 6 additions & 2 deletions ui/next/components/Dashboard/stats.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
export default function Statistic() {
interface StatisticProps {
count: number;
}

export default function Statistic({ count }: StatisticProps) {
return (
<div className="px-4 py-4 my-3 rounded mx-auto sm:max-w-xl md:max-w-full lg:max-w-screen-xl md:px-14 lg:px-8 lg:py-10 bg-white">
<div className="flex flex-col lg:items-center lg:flex-row">
Expand All @@ -19,7 +23,7 @@ export default function Statistic() {
</svg>
</div>
<h3 className="text-4xl font-extrabold sm:text-5xl xl:text-6xl">
9 312 435
{count}
</h3>
</div>
<div className="lg:w-1/2">
Expand Down

0 comments on commit 1a9e2ee

Please sign in to comment.