Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/endpoint-for-swagger'
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-tron committed Dec 12, 2024
2 parents 81b3f8e + 9aa7ffc commit c4c038d
Show file tree
Hide file tree
Showing 10 changed files with 509 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ RUN go mod download
COPY internal internal
COPY cmd cmd
COPY pkg pkg
RUN mkdir -p /tmp/openapi
COPY api/openapi.json /tmp/openapi/openapi.json
COPY api/openapi.yml /tmp/openapi/openapi.yml

RUN apt-get update && \
apt-get install -y libsecp256k1-0 libsodium23
Expand All @@ -20,4 +23,6 @@ RUN mkdir -p /app/lib
RUN wget -O /app/lib/libemulator.so https://github.com/ton-blockchain/ton/releases/download/v2024.08/libemulator-linux-x86_64.so
ENV LD_LIBRARY_PATH=/app/lib/
COPY --from=gobuild /tmp/opentonapi /usr/bin/
COPY --from=gobuild /tmp/openapi /app/openapi
WORKDIR /app
CMD ["/usr/bin/opentonapi"]
45 changes: 45 additions & 0 deletions api/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -9944,6 +9944,51 @@
]
}
},
"/v2/openapi.json": {
"get": {
"description": "Get the openapi.json file",
"operationId": "getOpenapiJson",
"responses": {
"200": {
"content": {
"application/json": {
"schema": {}
}
}
},
"default": {
"$ref": "#/components/responses/Error"
}
},
"tags": [
"Openapi"
]
}
},
"/v2/openapi.yml": {
"get": {
"description": "Get the openapi.yml file",
"operationId": "getOpenapiYml",
"responses": {
"200": {
"content": {
"application/x-yaml": {
"schema": {
"format": "binary",
"type": "string"
}
}
}
},
"default": {
"$ref": "#/components/responses/Error"
}
},
"tags": [
"Openapi"
]
}
},
"/v2/pubkeys/{public_key}/wallets": {
"get": {
"description": "Get wallets by public key",
Expand Down
28 changes: 28 additions & 0 deletions api/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,34 @@ tags:
url: https://docs.tonconsole.com/tonapi/rest-api/utilities

paths:
/v2/openapi.json:
get:
description: Get the openapi.json file
operationId: getOpenapiJson
tags:
- Openapi
responses:
'200':
content:
application/json:
schema: { } # Free-form JSON value
'default':
$ref: '#/components/responses/Error'
/v2/openapi.yml:
get:
description: Get the openapi.yml file
operationId: getOpenapiYml
tags:
- Openapi
responses:
'200':
content:
application/x-yaml:
schema:
type: string
format: binary
'default':
$ref: '#/components/responses/Error'
/v2/status:
get:
description: Status
Expand Down
33 changes: 33 additions & 0 deletions pkg/api/openapi.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package api

import (
"bytes"
"context"
"github.com/go-faster/jx"
"github.com/tonkeeper/opentonapi/pkg/oas"
"net/http"
"os"
)

func (h *Handler) GetOpenapiJson(ctx context.Context) (jx.Raw, error) {
file, err := os.ReadFile("openapi/openapi.json")
if err != nil {
return jx.Raw{}, toError(http.StatusInternalServerError, err)
}
d := jx.DecodeBytes(file)
result, err := d.Raw()
if err != nil {
return jx.Raw{}, toError(http.StatusInternalServerError, err)
}
return result, nil
}

func (h *Handler) GetOpenapiYml(ctx context.Context) (oas.GetOpenapiYmlOK, error) {
file, err := os.ReadFile("openapi/openapi.yml")
if err != nil {
return oas.GetOpenapiYmlOK{}, toError(http.StatusInternalServerError, err)
}
return oas.GetOpenapiYmlOK{
Data: bytes.NewReader(file),
}, nil
}
197 changes: 197 additions & 0 deletions pkg/oas/oas_handlers_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions pkg/oas/oas_response_encoders_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c4c038d

Please sign in to comment.