Skip to content

Commit c4c038d

Browse files
committed
Merge remote-tracking branch 'origin/endpoint-for-swagger'
2 parents 81b3f8e + 9aa7ffc commit c4c038d

10 files changed

+509
-0
lines changed

Dockerfile

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ RUN go mod download
66
COPY internal internal
77
COPY cmd cmd
88
COPY pkg pkg
9+
RUN mkdir -p /tmp/openapi
10+
COPY api/openapi.json /tmp/openapi/openapi.json
11+
COPY api/openapi.yml /tmp/openapi/openapi.yml
912

1013
RUN apt-get update && \
1114
apt-get install -y libsecp256k1-0 libsodium23
@@ -20,4 +23,6 @@ RUN mkdir -p /app/lib
2023
RUN wget -O /app/lib/libemulator.so https://github.com/ton-blockchain/ton/releases/download/v2024.08/libemulator-linux-x86_64.so
2124
ENV LD_LIBRARY_PATH=/app/lib/
2225
COPY --from=gobuild /tmp/opentonapi /usr/bin/
26+
COPY --from=gobuild /tmp/openapi /app/openapi
27+
WORKDIR /app
2328
CMD ["/usr/bin/opentonapi"]

api/openapi.json

+45
Original file line numberDiff line numberDiff line change
@@ -9944,6 +9944,51 @@
99449944
]
99459945
}
99469946
},
9947+
"/v2/openapi.json": {
9948+
"get": {
9949+
"description": "Get the openapi.json file",
9950+
"operationId": "getOpenapiJson",
9951+
"responses": {
9952+
"200": {
9953+
"content": {
9954+
"application/json": {
9955+
"schema": {}
9956+
}
9957+
}
9958+
},
9959+
"default": {
9960+
"$ref": "#/components/responses/Error"
9961+
}
9962+
},
9963+
"tags": [
9964+
"Openapi"
9965+
]
9966+
}
9967+
},
9968+
"/v2/openapi.yml": {
9969+
"get": {
9970+
"description": "Get the openapi.yml file",
9971+
"operationId": "getOpenapiYml",
9972+
"responses": {
9973+
"200": {
9974+
"content": {
9975+
"application/x-yaml": {
9976+
"schema": {
9977+
"format": "binary",
9978+
"type": "string"
9979+
}
9980+
}
9981+
}
9982+
},
9983+
"default": {
9984+
"$ref": "#/components/responses/Error"
9985+
}
9986+
},
9987+
"tags": [
9988+
"Openapi"
9989+
]
9990+
}
9991+
},
99479992
"/v2/pubkeys/{public_key}/wallets": {
99489993
"get": {
99499994
"description": "Get wallets by public key",

api/openapi.yml

+28
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,34 @@ tags:
8686
url: https://docs.tonconsole.com/tonapi/rest-api/utilities
8787

8888
paths:
89+
/v2/openapi.json:
90+
get:
91+
description: Get the openapi.json file
92+
operationId: getOpenapiJson
93+
tags:
94+
- Openapi
95+
responses:
96+
'200':
97+
content:
98+
application/json:
99+
schema: { } # Free-form JSON value
100+
'default':
101+
$ref: '#/components/responses/Error'
102+
/v2/openapi.yml:
103+
get:
104+
description: Get the openapi.yml file
105+
operationId: getOpenapiYml
106+
tags:
107+
- Openapi
108+
responses:
109+
'200':
110+
content:
111+
application/x-yaml:
112+
schema:
113+
type: string
114+
format: binary
115+
'default':
116+
$ref: '#/components/responses/Error'
89117
/v2/status:
90118
get:
91119
description: Status

pkg/api/openapi.go

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package api
2+
3+
import (
4+
"bytes"
5+
"context"
6+
"github.com/go-faster/jx"
7+
"github.com/tonkeeper/opentonapi/pkg/oas"
8+
"net/http"
9+
"os"
10+
)
11+
12+
func (h *Handler) GetOpenapiJson(ctx context.Context) (jx.Raw, error) {
13+
file, err := os.ReadFile("openapi/openapi.json")
14+
if err != nil {
15+
return jx.Raw{}, toError(http.StatusInternalServerError, err)
16+
}
17+
d := jx.DecodeBytes(file)
18+
result, err := d.Raw()
19+
if err != nil {
20+
return jx.Raw{}, toError(http.StatusInternalServerError, err)
21+
}
22+
return result, nil
23+
}
24+
25+
func (h *Handler) GetOpenapiYml(ctx context.Context) (oas.GetOpenapiYmlOK, error) {
26+
file, err := os.ReadFile("openapi/openapi.yml")
27+
if err != nil {
28+
return oas.GetOpenapiYmlOK{}, toError(http.StatusInternalServerError, err)
29+
}
30+
return oas.GetOpenapiYmlOK{
31+
Data: bytes.NewReader(file),
32+
}, nil
33+
}

pkg/oas/oas_handlers_gen.go

+197
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/oas/oas_response_encoders_gen.go

+30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)