Add OpenAPI spec for new API, and wire up a new API handler

Based on Aura and JSONAPI
This commit is contained in:
Deluan 2023-03-18 20:09:41 -04:00 • committed by Deluan
commit dcb5725642
16 changed files with 2660 additions and 46 deletions

94
server/api/api.go Normal file
View file

@ -0,0 +1,94 @@
//go:generate go run github.com/deepmap/oapi-codegen/cmd/oapi-codegen -config ./openapi_api.cfg.yaml "../../api/spec.yml"
//go:generate go run github.com/deepmap/oapi-codegen/cmd/oapi-codegen -config ./openapi_types.cfg.yaml "../../api/spec.yml"
package api
import (
"context"
"net/http"
"net/url"
middleware "github.com/deepmap/oapi-codegen/pkg/chi-middleware"
"github.com/getkin/kin-openapi/openapi3"
"github.com/go-chi/chi/v5"
"github.com/navidrome/navidrome/consts"
"github.com/navidrome/navidrome/model"
)
var spec = func() *openapi3.T {
s, _ := GetSwagger()
//s.Servers = nil
//s.Components.SecuritySchemes = nil
s.Security = nil //TODO
return s
}()
func New(ds model.DataStore) *Router {
r := &Router{ds: ds}
mux := chi.NewRouter()
mux.Use(middleware.OapiRequestValidatorWithOptions(spec, &middleware.Options{
ErrorHandler: validationErrorHandler,
}))
handler := NewStrictHandlerWithOptions(r, nil, StrictHTTPServerOptions{
RequestErrorHandlerFunc: apiErrorHandler,
ResponseErrorHandlerFunc: apiErrorHandler,
})
r.Handler = HandlerFromMux(handler, mux)
return r
}
var _ StrictServerInterface = (*Router)(nil)
type Router struct {
http.Handler
ds model.DataStore
}
func (a *Router) GetArtists(ctx context.Context, request GetArtistsRequestObject) (GetArtistsResponseObject, error) {
//TODO implement me
panic("implement me")
}
func (a *Router) GetArtist(ctx context.Context, request GetArtistRequestObject) (GetArtistResponseObject, error) {
//TODO implement me
panic("implement me")
}
func (a *Router) GetServerInfo(_ context.Context, _ GetServerInfoRequestObject) (GetServerInfoResponseObject, error) {
return GetServerInfo200JSONResponse{
Data: ServerInfo{
AuthRequired: true,
Features: []ServerInfoFeatures{},
Server: consts.AppName,
ServerVersion: consts.Version,
},
}, nil
}
func (a *Router) GetTracks(ctx context.Context, request GetTracksRequestObject) (GetTracksResponseObject, error) {
options := toQueryOptions(request.Params)
mfs, err := a.ds.MediaFile(ctx).GetAll(options)
if err != nil {
return nil, err
}
cnt, err := a.ds.MediaFile(ctx).CountAll(options)
if err != nil {
return nil, err
}
baseUrl, _ := url.JoinPath(spec.Servers[0].URL, "tracks")
links, meta := buildPaginationLinksAndMeta(int32(cnt), request.Params, baseUrl)
return GetTracks200JSONResponse{
Data: toAPITracks(mfs),
Links: links,
Meta: &meta,
}, nil
}
func (a *Router) GetTrack(ctx context.Context, request GetTrackRequestObject) (GetTrackResponseObject, error) {
mf, err := a.ds.MediaFile(ctx).Get(request.TrackId)
if err != nil {
return nil, err
}
return GetTrack200JSONResponse{Data: toAPITrack(*mf)}, nil
}

View file

@ -0,0 +1,17 @@
package api
import (
"testing"
"github.com/navidrome/navidrome/log"
"github.com/navidrome/navidrome/tests"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
func TestApi(t *testing.T) {
tests.Init(t, false)
log.SetLevel(log.LevelFatal)
RegisterFailHandler(Fail)
RunSpecs(t, "Navidrome JSON:API Suite")
}

193
server/api/helpers.go Normal file
View file

@ -0,0 +1,193 @@
package api
import (
"encoding/json"
"net/http"
"net/url"
"strconv"
"strings"
"github.com/Masterminds/squirrel"
"github.com/navidrome/navidrome/model"
)
func toAPITrack(mf model.MediaFile) Track {
return Track{
Type: "track",
Id: mf.ID,
Attributes: &TrackAttributes{
Album: mf.Album,
//Albumartist: mf.AlbumArtist,
Artist: mf.Artist,
//Bitrate: mf.BitRate,
//Bpm: p(mf.Bpm),
//Channels: mf.Channels,
//Comments: p(mf.Comment),
//Disc: p(mf.DiscNumber),
Duration: mf.Duration,
//Genre: p(mf.Genre),
//Mimetype: mf.ContentType(),
//RecordingMbid: p(mf.MbzTrackID),
//Size: int(mf.Size),
Title: mf.Title,
//Track: mf.TrackNumber,
//TrackMbid: p(mf.MbzReleaseTrackID),
//Year: p(mf.Year),
},
}
}
func toAPITracks(mfs model.MediaFiles) []Track {
tracks := make([]Track, len(mfs))
for i := range mfs {
tracks[i] = toAPITrack(mfs[i])
}
return tracks
}
func p[T comparable](t T) *T {
var zero T
if t == zero {
return nil
}
return &t
}
func v[T comparable](p *T) T {
var zero T
if p == nil {
return zero
}
return *p
}
// toQueryOptions convert a params struct to a model.QueryOptions struct, to be used by the
// GetAll and CountAll functions. It assumes all GetXxxxParams functions have the exact same structure.
func toQueryOptions(params GetTracksParams) model.QueryOptions {
var filters squirrel.And
parseFilter := func(fs *[]string, op func(f, v string) squirrel.Sqlizer) {
if fs != nil {
for _, f := range *fs {
parts := strings.SplitN(f, ":", 2)
filters = append(filters, op(parts[0], parts[1]))
}
}
}
parseFilter(params.FilterEquals, func(f, v string) squirrel.Sqlizer { return squirrel.Eq{f: v} })
parseFilter(params.FilterContains, func(f, v string) squirrel.Sqlizer { return squirrel.Like{f: "%" + v + "%"} })
parseFilter(params.FilterStartsWith, func(f, v string) squirrel.Sqlizer { return squirrel.Like{f: v + "%"} })
parseFilter(params.FilterEndsWith, func(f, v string) squirrel.Sqlizer { return squirrel.Like{f: "%" + v} })
parseFilter(params.FilterGreaterThan, func(f, v string) squirrel.Sqlizer { return squirrel.Gt{f: v} })
parseFilter(params.FilterGreaterOrEqual, func(f, v string) squirrel.Sqlizer { return squirrel.GtOrEq{f: v} })
parseFilter(params.FilterLessThan, func(f, v string) squirrel.Sqlizer { return squirrel.Lt{f: v} })
parseFilter(params.FilterLessOrEqual, func(f, v string) squirrel.Sqlizer { return squirrel.LtOrEq{f: v} })
offset := v(params.PageOffset)
limit := v(params.PageLimit)
return model.QueryOptions{Max: int(limit), Offset: int(offset), Filters: filters}
}
func apiErrorHandler(w http.ResponseWriter, r *http.Request, err error) {
var res ErrorObject
switch err {
case model.ErrNotAuthorized:
res = ErrorObject{Status: p(strconv.Itoa(http.StatusForbidden)), Title: p(http.StatusText(http.StatusForbidden))}
case model.ErrNotFound:
res = ErrorObject{Status: p(strconv.Itoa(http.StatusNotFound)), Title: p(http.StatusText(http.StatusNotFound))}
default:
res = ErrorObject{Status: p(strconv.Itoa(http.StatusInternalServerError)), Title: p(http.StatusText(http.StatusInternalServerError))}
}
w.Header().Set("Content-Type", "application/vnd.api+json")
w.WriteHeader(403)
json.NewEncoder(w).Encode(ErrorList{[]ErrorObject{res}})
}
func validationErrorHandler(w http.ResponseWriter, message string, statusCode int) {
_ = GetTracks400JSONResponse{BadRequestJSONResponse{Errors: []ErrorObject{
{
Status: p(strconv.Itoa(statusCode)),
Title: p(http.StatusText(statusCode)),
Detail: p(message),
},
}}}.VisitGetTracksResponse(w)
}
func buildPaginationLinksAndMeta(totalItems int32, params GetTracksParams, resourceName string) (PaginationLinks, PaginationMeta) {
pageLimit := *params.PageLimit
pageOffset := *params.PageOffset
totalPages := (totalItems + pageLimit - 1) / pageLimit
currentPage := pageOffset/pageLimit + 1
meta := PaginationMeta{
CurrentPage: &currentPage,
TotalItems: &totalItems,
TotalPages: &totalPages,
}
var first, last, next, prev *string
buildLink := func(page int32) *string {
query := url.Values{}
query.Add("page[offset]", strconv.Itoa(int(page*pageLimit)))
query.Add("page[limit]", strconv.Itoa(int(pageLimit)))
addFilterParams := func(paramName string, values *[]string) {
if values == nil {
return
}
for _, value := range *values {
query.Add(paramName, value)
}
}
addFilterParams("filter[equals]", params.FilterEquals)
addFilterParams("filter[contains]", params.FilterContains)
addFilterParams("filter[lessThan]", params.FilterLessThan)
addFilterParams("filter[lessOrEqual]", params.FilterLessOrEqual)
addFilterParams("filter[greaterThan]", params.FilterGreaterThan)
addFilterParams("filter[greaterOrEqual]", params.FilterGreaterOrEqual)
addFilterParams("filter[startsWith]", params.FilterStartsWith)
addFilterParams("filter[endsWith]", params.FilterEndsWith)
if params.Sort != nil {
query.Add("sort", string(*params.Sort))
}
if params.Include != nil {
query.Add("include", string(*params.Include))
}
link := resourceName
if len(query) > 0 {
link += "&" + query.Encode()
}
return &link
}
if totalPages > 0 {
firstLink := buildLink(0)
first = firstLink
lastLink := buildLink(totalPages - 1)
last = lastLink
}
if currentPage < totalPages {
nextLink := buildLink(currentPage)
next = nextLink
}
if currentPage > 1 {
prevLink := buildLink(currentPage - 2)
prev = prevLink
}
links := PaginationLinks{
First: first,
Last: last,
Next: next,
Prev: prev,
}
return links, meta
}

110
server/api/helpers_test.go Normal file
View file

@ -0,0 +1,110 @@
package api
import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = Describe("BuildPaginationLinksAndMeta", func() {
var (
totalItems int32
params GetTracksParams
resourceName string
)
BeforeEach(func() {
totalItems = 150
resourceName = "api/resource"
})
Context("with default page limit and offset", func() {
BeforeEach(func() {
l, o := int32(10), int32(0)
params = GetTracksParams{
PageLimit: &l,
PageOffset: &o,
}
})
It("returns correct pagination links and meta", func() {
links, meta := buildPaginationLinksAndMeta(totalItems, params, resourceName)
Expect(links.First).To(Equal(p("api/resource?page[offset]=0&page[limit]=10")))
Expect(links.Last).To(Equal(p("api/resource?page[offset]=140&page[limit]=10")))
Expect(links.Next).To(Equal(p("api/resource?page[offset]=10&page[limit]=10")))
Expect(links.Prev).To(BeNil())
Expect(meta.CurrentPage).To(Equal(p(int32(1))))
Expect(meta.TotalItems).To(Equal(p(int32(150))))
Expect(meta.TotalPages).To(Equal(p(int32(15))))
})
})
Context("with custom page limit and offset", func() {
BeforeEach(func() {
params = GetTracksParams{
PageLimit: p((PageLimit)(20)),
PageOffset: p((PageOffset)(40)),
}
})
It("returns correct pagination links and meta", func() {
links, meta := buildPaginationLinksAndMeta(totalItems, params, resourceName)
Expect(links.First).To(Equal(p("api/resource?page[offset]=0&page[limit]=20")))
Expect(links.Last).To(Equal(p("api/resource?page[offset]=140&page[limit]=20")))
Expect(links.Next).To(Equal(p("api/resource?page[offset]=60&page[limit]=20")))
Expect(links.Prev).To(Equal(p("api/resource?page[offset]=20&page[limit]=20")))
Expect(meta.CurrentPage).To(Equal(p(int32(3))))
Expect(meta.TotalItems).To(Equal(p(int32(150))))
Expect(meta.TotalPages).To(Equal(p(int32(8))))
})
})
Context("with various filter params", func() {
BeforeEach(func() {
params = GetTracksParams{
PageLimit: p((PageLimit)(20)),
PageOffset: p((PageOffset)(40)),
FilterEquals: &[]string{"property1:value1", "property2:value2"},
FilterContains: &[]string{"property3:value3"},
FilterLessThan: &[]string{"property4:value4"},
FilterLessOrEqual: &[]string{"property5:value5"},
FilterGreaterThan: &[]string{"property6:value6"},
FilterGreaterOrEqual: &[]string{"property7:value7"},
FilterStartsWith: &[]string{"property8:value8"},
FilterEndsWith: &[]string{"property9:value9"},
}
})
It("returns correct pagination links with filter params", func() {
links, _ := buildPaginationLinksAndMeta(totalItems, params, resourceName)
expectedLinkPrefix := "api/resource?"
expectedParams := []string{
"page[offset]=0&page[limit]=20",
"filter[equals]=property1:value1&filter[equals]=property2:value2",
"filter[contains]=property3:value3",
"filter[lessThan]=property4:value4",
"filter[lessOrEqual]=property5:value5",
"filter[greaterThan]=property6:value6",
"filter[greaterOrEqual]=property7:value7",
"filter[startsWith]=property8:value8",
"filter[endsWith]=property9:value9",
}
Expect(*links.First).To(HavePrefix(expectedLinkPrefix))
Expect(*links.Last).To(HavePrefix(expectedLinkPrefix))
Expect(*links.Next).To(HavePrefix(expectedLinkPrefix))
Expect(*links.Prev).To(HavePrefix(expectedLinkPrefix))
for _, param := range expectedParams {
Expect(*links.First).To(ContainSubstring(param))
Expect(*links.Last).To(ContainSubstring(param))
Expect(*links.Next).To(ContainSubstring(param))
Expect(*links.Prev).To(ContainSubstring(param))
}
})
})
})

View file

@ -0,0 +1,6 @@
package: api
generate:
chi-server: true
strict-server: true
embedded-spec: true
output: openapi_api.gen.go

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,4 @@
package: api
generate:
models: true
output: openapi_types.gen.go

View file

@ -0,0 +1,282 @@
// Package api provides primitives to interact with the openapi HTTP API.
//
// Code generated by github.com/deepmap/oapi-codegen version v1.12.5-0.20230314231417-0cfaaa77a7d2 DO NOT EDIT.
package api
// Defines values for ArtistRole.
const (
AlbumArtist ArtistRole = "albumArtist"
Composer ArtistRole = "composer"
Vocalist ArtistRole = "vocalist"
)
// Defines values for ServerInfoFeatures.
const (
Albums ServerInfoFeatures = "albums"
Artists ServerInfoFeatures = "artists"
Images ServerInfoFeatures = "images"
)
// Artist defines model for Artist.
type Artist struct {
Attributes *ArtistAttributes `json:"attributes,omitempty"`
// Id The unique identifier for the resource
Id string `json:"id"`
Relationships *struct {
Tracks struct {
Data []ArtistTrackRelationship `json:"data"`
} `json:"tracks"`
} `json:"relationships,omitempty"`
// Type The type of the resource
Type string `json:"type"`
}
// ArtistAttributes defines model for ArtistAttributes.
type ArtistAttributes struct {
// Bio A short biography of the artist
Bio *string `json:"bio,omitempty"`
// Name The name of the artist
Name *string `json:"name,omitempty"`
}
// ArtistRole The role of an artist in a track or album
type ArtistRole string
// ArtistTrackRelationship defines model for ArtistTrackRelationship.
type ArtistTrackRelationship struct {
Data ResourceObject `json:"data"`
Meta struct {
// Role The role of an artist in a track or album
Role ArtistRole `json:"role"`
} `json:"meta"`
}
// ErrorList defines model for ErrorList.
type ErrorList struct {
Errors []ErrorObject `json:"errors"`
}
// ErrorObject defines model for ErrorObject.
type ErrorObject struct {
Detail *string `json:"detail,omitempty"`
Id *string `json:"id,omitempty"`
Status *string `json:"status,omitempty"`
Title *string `json:"title,omitempty"`
}
// PaginationLinks defines model for PaginationLinks.
type PaginationLinks struct {
First *string `json:"first,omitempty"`
Last *string `json:"last,omitempty"`
Next *string `json:"next,omitempty"`
Prev *string `json:"prev,omitempty"`
}
// PaginationMeta defines model for PaginationMeta.
type PaginationMeta struct {
// CurrentPage The current page in the collection
CurrentPage *int32 `json:"currentPage,omitempty"`
// TotalItems The total number of items in the collection
TotalItems *int32 `json:"totalItems,omitempty"`
// TotalPages The total numeber of pages in the collection
TotalPages *int32 `json:"totalPages,omitempty"`
}
// ResourceObject defines model for ResourceObject.
type ResourceObject struct {
// Id The unique identifier for the resource
Id string `json:"id"`
// Type The type of the resource
Type string `json:"type"`
}
// ServerInfo defines model for ServerInfo.
type ServerInfo struct {
// AuthRequired Whether the user has access to the server.
AuthRequired bool `json:"authRequired"`
// Features A list of optional features the server supports.
Features []ServerInfoFeatures `json:"features"`
// Server The name of the server software.
Server string `json:"server"`
// ServerVersion The version number of the server.
ServerVersion string `json:"serverVersion"`
}
// ServerInfoFeatures defines model for ServerInfo.Features.
type ServerInfoFeatures string
// Track defines model for Track.
type Track struct {
Attributes *TrackAttributes `json:"attributes,omitempty"`
// Id The unique identifier for the resource
Id string `json:"id"`
Relationships *struct {
Artists *[]TrackArtistRelationship `json:"artists,omitempty"`
} `json:"relationships,omitempty"`
// Type The type of the resource
Type string `json:"type"`
}
// TrackArtistRelationship defines model for TrackArtistRelationship.
type TrackArtistRelationship struct {
Data ResourceObject `json:"data"`
Meta struct {
// Role The role of an artist in a track or album
Role ArtistRole `json:"role"`
} `json:"meta"`
}
// TrackAttributes defines model for TrackAttributes.
type TrackAttributes struct {
// Album The name of the album the track belongs to
Album string `json:"album"`
// Artist The name of the artist who performed the track
Artist string `json:"artist"`
// Composer The name of the composer who created the track
Composer *string `json:"composer,omitempty"`
// Duration The duration of the track in seconds
Duration float32 `json:"duration"`
// Title The title of the track
Title string `json:"title"`
}
// FilterContains defines model for filterContains.
type FilterContains = []string
// FilterEndsWith defines model for filterEndsWith.
type FilterEndsWith = []string
// FilterEquals defines model for filterEquals.
type FilterEquals = []string
// FilterGreaterOrEqual defines model for filterGreaterOrEqual.
type FilterGreaterOrEqual = []string
// FilterGreaterThan defines model for filterGreaterThan.
type FilterGreaterThan = []string
// FilterLessOrEqual defines model for filterLessOrEqual.
type FilterLessOrEqual = []string
// FilterLessThan defines model for filterLessThan.
type FilterLessThan = []string
// FilterStartsWith defines model for filterStartsWith.
type FilterStartsWith = []string
// Include defines model for include.
type Include = string
// PageLimit defines model for pageLimit.
type PageLimit = int32
// PageOffset defines model for pageOffset.
type PageOffset = int32
// Sort defines model for sort.
type Sort = string
// GetArtistsParams defines parameters for GetArtists.
type GetArtistsParams struct {
// PageLimit The number of items per page
PageLimit *PageLimit `form:"page[limit],omitempty" json:"page[limit],omitempty"`
// PageOffset The offset for pagination
PageOffset *PageOffset `form:"page[offset],omitempty" json:"page[offset],omitempty"`
// FilterEquals Filter by any property with an exact match. Usage: filter[equals]=property:value
FilterEquals *FilterEquals `form:"filter[equals],omitempty" json:"filter[equals],omitempty"`
// FilterContains Filter by any property containing text. Usage: filter[contains]=property:value
FilterContains *FilterContains `form:"filter[contains],omitempty" json:"filter[contains],omitempty"`
// FilterLessThan Filter by any numeric property less than a value. Usage: filter[lessThan]=property:value
FilterLessThan *FilterLessThan `form:"filter[lessThan],omitempty" json:"filter[lessThan],omitempty"`
// FilterLessOrEqual Filter by any numeric property less than or equal to a value. Usage: filter[lessOrEqual]=property:value
FilterLessOrEqual *FilterLessOrEqual `form:"filter[lessOrEqual],omitempty" json:"filter[lessOrEqual],omitempty"`
// FilterGreaterThan Filter by any numeric property greater than a value. Usage: filter[greaterThan]=property:value
FilterGreaterThan *FilterGreaterThan `form:"filter[greaterThan],omitempty" json:"filter[greaterThan],omitempty"`
// FilterGreaterOrEqual Filter by any numeric property greater than or equal to a value. Usage: filter[greaterOrEqual]=property:value
FilterGreaterOrEqual *FilterGreaterOrEqual `form:"filter[greaterOrEqual],omitempty" json:"filter[greaterOrEqual],omitempty"`
// FilterStartsWith Filter by any property that starts with text. Usage: filter[startsWith]=property:value
FilterStartsWith *FilterStartsWith `form:"filter[startsWith],omitempty" json:"filter[startsWith],omitempty"`
// FilterEndsWith Filter by any property that ends with text. Usage: filter[endsWith]=property:value
FilterEndsWith *FilterEndsWith `form:"filter[endsWith],omitempty" json:"filter[endsWith],omitempty"`
// Sort Sort the results by one or more properties, separated by commas. Prefix the property with '-' for descending order.
Sort *Sort `form:"sort,omitempty" json:"sort,omitempty"`
// Include Related resources to include in the response, separated by commas
Include *Include `form:"include,omitempty" json:"include,omitempty"`
}
// GetArtistParams defines parameters for GetArtist.
type GetArtistParams struct {
// Include Related resources to include in the response, separated by commas
Include *Include `form:"include,omitempty" json:"include,omitempty"`
}
// GetTracksParams defines parameters for GetTracks.
type GetTracksParams struct {
// PageLimit The number of items per page
PageLimit *PageLimit `form:"page[limit],omitempty" json:"page[limit],omitempty"`
// PageOffset The offset for pagination
PageOffset *PageOffset `form:"page[offset],omitempty" json:"page[offset],omitempty"`
// FilterEquals Filter by any property with an exact match. Usage: filter[equals]=property:value
FilterEquals *FilterEquals `form:"filter[equals],omitempty" json:"filter[equals],omitempty"`
// FilterContains Filter by any property containing text. Usage: filter[contains]=property:value
FilterContains *FilterContains `form:"filter[contains],omitempty" json:"filter[contains],omitempty"`
// FilterLessThan Filter by any numeric property less than a value. Usage: filter[lessThan]=property:value
FilterLessThan *FilterLessThan `form:"filter[lessThan],omitempty" json:"filter[lessThan],omitempty"`
// FilterLessOrEqual Filter by any numeric property less than or equal to a value. Usage: filter[lessOrEqual]=property:value
FilterLessOrEqual *FilterLessOrEqual `form:"filter[lessOrEqual],omitempty" json:"filter[lessOrEqual],omitempty"`
// FilterGreaterThan Filter by any numeric property greater than a value. Usage: filter[greaterThan]=property:value
FilterGreaterThan *FilterGreaterThan `form:"filter[greaterThan],omitempty" json:"filter[greaterThan],omitempty"`
// FilterGreaterOrEqual Filter by any numeric property greater than or equal to a value. Usage: filter[greaterOrEqual]=property:value
FilterGreaterOrEqual *FilterGreaterOrEqual `form:"filter[greaterOrEqual],omitempty" json:"filter[greaterOrEqual],omitempty"`
// FilterStartsWith Filter by any property that starts with text. Usage: filter[startsWith]=property:value
FilterStartsWith *FilterStartsWith `form:"filter[startsWith],omitempty" json:"filter[startsWith],omitempty"`
// FilterEndsWith Filter by any property that ends with text. Usage: filter[endsWith]=property:value
FilterEndsWith *FilterEndsWith `form:"filter[endsWith],omitempty" json:"filter[endsWith],omitempty"`
// Sort Sort the results by one or more properties, separated by commas. Prefix the property with '-' for descending order.
Sort *Sort `form:"sort,omitempty" json:"sort,omitempty"`
// Include Related resources to include in the response, separated by commas
Include *Include `form:"include,omitempty" json:"include,omitempty"`
}
// GetTrackParams defines parameters for GetTrack.
type GetTrackParams struct {
// Include Related resources to include in the response, separated by commas
Include *Include `form:"include,omitempty" json:"include,omitempty"`
}