Skip to content

Commit

Permalink
Add slice endpoint documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ErlendHaa committed Aug 16, 2022
1 parent f6ff9f8 commit 5ad553e
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ ARG CGO_CPPFLAGS="-I/open-vds/Dist/OpenVDS/include"
ARG CGO_LDFLAGS="-L/open-vds/Dist/OpenVDS/lib"
RUN go build -a ./...
RUN GOBIN=/tools go install github.com/swaggo/swag/cmd/swag@latest
RUN /tools/swag init -g cmd/query/main.go
RUN /tools/swag init -g cmd/query/main.go --md docs


FROM builder as tester
Expand Down
15 changes: 15 additions & 0 deletions api/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ func (e *Endpoint) Health(ctx *gin.Context) {
ctx.String(http.StatusOK, "I am up and running")
}

// SliceGet godoc
// @Summary Fetch a slice from a VDS
// @description.markdown slice
// @Param query query string True "Urlencoded/escaped SliceQuery"
// @Produce multipart/mixed
// @Success 200 {object} vds.Metadata "(Example below only for metadata part)"
// @Router /slice [get]
func (e *Endpoint) SliceGet(ctx *gin.Context) {
var query SliceQuery
if err := parseGetRequest(ctx, &query); err != nil {
Expand All @@ -99,6 +106,14 @@ func (e *Endpoint) SliceGet(ctx *gin.Context) {
e.slice(ctx, query)
}

// SlicePost godoc
// @Summary Fetch metadata related to a single slice
// @description.markdown slice
// @Param body body SliceQuery True "Query Parameters"
// @Accept application/json
// @Produce multipart/mixed
// @Success 200 {object} vds.Metadata "(Example below only for metadata part)"
// @Router /slice [post]
func (e *Endpoint) SlicePost(ctx *gin.Context) {
var query SliceQuery
if err := ctx.ShouldBind(&query); err != nil {
Expand Down
22 changes: 22 additions & 0 deletions docs/slice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Fetch a slice form a VDS

Fetch a slice in any direction. Support 0-indexing of lines
and index-by-annotation such as inline and crossline numbers
and depth intervals. See model SliceData for more info
on request parameters.

## Response
On success (200) the response consists of two parts, metadata
and data

### Metadata part
*Content-Type: application/json*
Metadata related to the returned slice, such as axis
dimensions, labels and units and data type. See the
Metadata data model.

### Data part
*Content-Type: application/octet-stream*
A raw byte array containing the slice itself. The byte array needs to be parsed
into a 2D array before use. Shape and type information is found in the metadata
part. Data is always little endian.

0 comments on commit 5ad553e

Please sign in to comment.