navidrome/server/api/openapi_api.gen.go
2023-06-07 10:49:56 -04:00

1393 lines
47 KiB
Go

// Package api provides primitives to interact with the openapi HTTP API.
//
// Code generated by github.com/deepmap/oapi-codegen version v1.12.5-0.20230513000919-14548c7e7bbe DO NOT EDIT.
package api
import (
"bytes"
"compress/gzip"
"context"
"encoding/base64"
"encoding/json"
"fmt"
"net/http"
"net/url"
"path"
"strings"
"github.com/deepmap/oapi-codegen/pkg/runtime"
"github.com/getkin/kin-openapi/openapi3"
"github.com/go-chi/chi/v5"
)
// ServerInterface represents all server handlers.
type ServerInterface interface {
// Retrieve a list of albums
// (GET /albums)
GetAlbums(w http.ResponseWriter, r *http.Request, params GetAlbumsParams)
// Retrieve an individual album
// (GET /albums/{albumId})
GetAlbum(w http.ResponseWriter, r *http.Request, albumId string, params GetAlbumParams)
// Retrieve a list of artists
// (GET /artists)
GetArtists(w http.ResponseWriter, r *http.Request, params GetArtistsParams)
// Retrieve an individual artist
// (GET /artists/{artistId})
GetArtist(w http.ResponseWriter, r *http.Request, artistId string, params GetArtistParams)
// Get server's global info
// (GET /server)
GetServerInfo(w http.ResponseWriter, r *http.Request)
// Retrieve a list of tracks
// (GET /tracks)
GetTracks(w http.ResponseWriter, r *http.Request, params GetTracksParams)
// Retrieve an individual track
// (GET /tracks/{trackId})
GetTrack(w http.ResponseWriter, r *http.Request, trackId string, params GetTrackParams)
}
// ServerInterfaceWrapper converts contexts to parameters.
type ServerInterfaceWrapper struct {
Handler ServerInterface
HandlerMiddlewares []MiddlewareFunc
ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}
type MiddlewareFunc func(http.Handler) http.Handler
// GetAlbums operation middleware
func (siw *ServerInterfaceWrapper) GetAlbums(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
var err error
ctx = context.WithValue(ctx, BearerAuthScopes, []string{})
// Parameter object where we will unmarshal all parameters from the context
var params GetAlbumsParams
// ------------- Optional query parameter "page[limit]" -------------
err = runtime.BindQueryParameter("form", true, false, "page[limit]", r.URL.Query(), &params.PageLimit)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "page[limit]", Err: err})
return
}
// ------------- Optional query parameter "page[offset]" -------------
err = runtime.BindQueryParameter("form", true, false, "page[offset]", r.URL.Query(), &params.PageOffset)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "page[offset]", Err: err})
return
}
// ------------- Optional query parameter "filter[equals]" -------------
err = runtime.BindQueryParameter("form", true, false, "filter[equals]", r.URL.Query(), &params.FilterEquals)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "filter[equals]", Err: err})
return
}
// ------------- Optional query parameter "filter[contains]" -------------
err = runtime.BindQueryParameter("form", true, false, "filter[contains]", r.URL.Query(), &params.FilterContains)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "filter[contains]", Err: err})
return
}
// ------------- Optional query parameter "filter[lessThan]" -------------
err = runtime.BindQueryParameter("form", true, false, "filter[lessThan]", r.URL.Query(), &params.FilterLessThan)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "filter[lessThan]", Err: err})
return
}
// ------------- Optional query parameter "filter[lessOrEqual]" -------------
err = runtime.BindQueryParameter("form", true, false, "filter[lessOrEqual]", r.URL.Query(), &params.FilterLessOrEqual)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "filter[lessOrEqual]", Err: err})
return
}
// ------------- Optional query parameter "filter[greaterThan]" -------------
err = runtime.BindQueryParameter("form", true, false, "filter[greaterThan]", r.URL.Query(), &params.FilterGreaterThan)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "filter[greaterThan]", Err: err})
return
}
// ------------- Optional query parameter "filter[greaterOrEqual]" -------------
err = runtime.BindQueryParameter("form", true, false, "filter[greaterOrEqual]", r.URL.Query(), &params.FilterGreaterOrEqual)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "filter[greaterOrEqual]", Err: err})
return
}
// ------------- Optional query parameter "filter[startsWith]" -------------
err = runtime.BindQueryParameter("form", true, false, "filter[startsWith]", r.URL.Query(), &params.FilterStartsWith)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "filter[startsWith]", Err: err})
return
}
// ------------- Optional query parameter "filter[endsWith]" -------------
err = runtime.BindQueryParameter("form", true, false, "filter[endsWith]", r.URL.Query(), &params.FilterEndsWith)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "filter[endsWith]", Err: err})
return
}
// ------------- Optional query parameter "sort" -------------
err = runtime.BindQueryParameter("form", true, false, "sort", r.URL.Query(), &params.Sort)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "sort", Err: err})
return
}
// ------------- Optional query parameter "include" -------------
err = runtime.BindQueryParameter("form", false, false, "include", r.URL.Query(), &params.Include)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "include", Err: err})
return
}
var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
siw.Handler.GetAlbums(w, r, params)
})
for _, middleware := range siw.HandlerMiddlewares {
handler = middleware(handler)
}
handler.ServeHTTP(w, r.WithContext(ctx))
}
// GetAlbum operation middleware
func (siw *ServerInterfaceWrapper) GetAlbum(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
var err error
// ------------- Path parameter "albumId" -------------
var albumId string
err = runtime.BindStyledParameterWithLocation("simple", false, "albumId", runtime.ParamLocationPath, chi.URLParam(r, "albumId"), &albumId)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "albumId", Err: err})
return
}
ctx = context.WithValue(ctx, BearerAuthScopes, []string{})
// Parameter object where we will unmarshal all parameters from the context
var params GetAlbumParams
// ------------- Optional query parameter "include" -------------
err = runtime.BindQueryParameter("form", false, false, "include", r.URL.Query(), &params.Include)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "include", Err: err})
return
}
var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
siw.Handler.GetAlbum(w, r, albumId, params)
})
for _, middleware := range siw.HandlerMiddlewares {
handler = middleware(handler)
}
handler.ServeHTTP(w, r.WithContext(ctx))
}
// GetArtists operation middleware
func (siw *ServerInterfaceWrapper) GetArtists(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
var err error
ctx = context.WithValue(ctx, BearerAuthScopes, []string{})
// Parameter object where we will unmarshal all parameters from the context
var params GetArtistsParams
// ------------- Optional query parameter "page[limit]" -------------
err = runtime.BindQueryParameter("form", true, false, "page[limit]", r.URL.Query(), &params.PageLimit)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "page[limit]", Err: err})
return
}
// ------------- Optional query parameter "page[offset]" -------------
err = runtime.BindQueryParameter("form", true, false, "page[offset]", r.URL.Query(), &params.PageOffset)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "page[offset]", Err: err})
return
}
// ------------- Optional query parameter "filter[equals]" -------------
err = runtime.BindQueryParameter("form", true, false, "filter[equals]", r.URL.Query(), &params.FilterEquals)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "filter[equals]", Err: err})
return
}
// ------------- Optional query parameter "filter[contains]" -------------
err = runtime.BindQueryParameter("form", true, false, "filter[contains]", r.URL.Query(), &params.FilterContains)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "filter[contains]", Err: err})
return
}
// ------------- Optional query parameter "filter[lessThan]" -------------
err = runtime.BindQueryParameter("form", true, false, "filter[lessThan]", r.URL.Query(), &params.FilterLessThan)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "filter[lessThan]", Err: err})
return
}
// ------------- Optional query parameter "filter[lessOrEqual]" -------------
err = runtime.BindQueryParameter("form", true, false, "filter[lessOrEqual]", r.URL.Query(), &params.FilterLessOrEqual)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "filter[lessOrEqual]", Err: err})
return
}
// ------------- Optional query parameter "filter[greaterThan]" -------------
err = runtime.BindQueryParameter("form", true, false, "filter[greaterThan]", r.URL.Query(), &params.FilterGreaterThan)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "filter[greaterThan]", Err: err})
return
}
// ------------- Optional query parameter "filter[greaterOrEqual]" -------------
err = runtime.BindQueryParameter("form", true, false, "filter[greaterOrEqual]", r.URL.Query(), &params.FilterGreaterOrEqual)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "filter[greaterOrEqual]", Err: err})
return
}
// ------------- Optional query parameter "filter[startsWith]" -------------
err = runtime.BindQueryParameter("form", true, false, "filter[startsWith]", r.URL.Query(), &params.FilterStartsWith)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "filter[startsWith]", Err: err})
return
}
// ------------- Optional query parameter "filter[endsWith]" -------------
err = runtime.BindQueryParameter("form", true, false, "filter[endsWith]", r.URL.Query(), &params.FilterEndsWith)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "filter[endsWith]", Err: err})
return
}
// ------------- Optional query parameter "sort" -------------
err = runtime.BindQueryParameter("form", true, false, "sort", r.URL.Query(), &params.Sort)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "sort", Err: err})
return
}
// ------------- Optional query parameter "include" -------------
err = runtime.BindQueryParameter("form", true, false, "include", r.URL.Query(), &params.Include)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "include", Err: err})
return
}
var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
siw.Handler.GetArtists(w, r, params)
})
for _, middleware := range siw.HandlerMiddlewares {
handler = middleware(handler)
}
handler.ServeHTTP(w, r.WithContext(ctx))
}
// GetArtist operation middleware
func (siw *ServerInterfaceWrapper) GetArtist(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
var err error
// ------------- Path parameter "artistId" -------------
var artistId string
err = runtime.BindStyledParameterWithLocation("simple", false, "artistId", runtime.ParamLocationPath, chi.URLParam(r, "artistId"), &artistId)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "artistId", Err: err})
return
}
ctx = context.WithValue(ctx, BearerAuthScopes, []string{})
// Parameter object where we will unmarshal all parameters from the context
var params GetArtistParams
// ------------- Optional query parameter "include" -------------
err = runtime.BindQueryParameter("form", true, false, "include", r.URL.Query(), &params.Include)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "include", Err: err})
return
}
var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
siw.Handler.GetArtist(w, r, artistId, params)
})
for _, middleware := range siw.HandlerMiddlewares {
handler = middleware(handler)
}
handler.ServeHTTP(w, r.WithContext(ctx))
}
// GetServerInfo operation middleware
func (siw *ServerInterfaceWrapper) GetServerInfo(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
ctx = context.WithValue(ctx, BearerAuthScopes, []string{})
var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
siw.Handler.GetServerInfo(w, r)
})
for _, middleware := range siw.HandlerMiddlewares {
handler = middleware(handler)
}
handler.ServeHTTP(w, r.WithContext(ctx))
}
// GetTracks operation middleware
func (siw *ServerInterfaceWrapper) GetTracks(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
var err error
ctx = context.WithValue(ctx, BearerAuthScopes, []string{})
// Parameter object where we will unmarshal all parameters from the context
var params GetTracksParams
// ------------- Optional query parameter "page[limit]" -------------
err = runtime.BindQueryParameter("form", true, false, "page[limit]", r.URL.Query(), &params.PageLimit)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "page[limit]", Err: err})
return
}
// ------------- Optional query parameter "page[offset]" -------------
err = runtime.BindQueryParameter("form", true, false, "page[offset]", r.URL.Query(), &params.PageOffset)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "page[offset]", Err: err})
return
}
// ------------- Optional query parameter "filter[equals]" -------------
err = runtime.BindQueryParameter("form", true, false, "filter[equals]", r.URL.Query(), &params.FilterEquals)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "filter[equals]", Err: err})
return
}
// ------------- Optional query parameter "filter[contains]" -------------
err = runtime.BindQueryParameter("form", true, false, "filter[contains]", r.URL.Query(), &params.FilterContains)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "filter[contains]", Err: err})
return
}
// ------------- Optional query parameter "filter[lessThan]" -------------
err = runtime.BindQueryParameter("form", true, false, "filter[lessThan]", r.URL.Query(), &params.FilterLessThan)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "filter[lessThan]", Err: err})
return
}
// ------------- Optional query parameter "filter[lessOrEqual]" -------------
err = runtime.BindQueryParameter("form", true, false, "filter[lessOrEqual]", r.URL.Query(), &params.FilterLessOrEqual)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "filter[lessOrEqual]", Err: err})
return
}
// ------------- Optional query parameter "filter[greaterThan]" -------------
err = runtime.BindQueryParameter("form", true, false, "filter[greaterThan]", r.URL.Query(), &params.FilterGreaterThan)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "filter[greaterThan]", Err: err})
return
}
// ------------- Optional query parameter "filter[greaterOrEqual]" -------------
err = runtime.BindQueryParameter("form", true, false, "filter[greaterOrEqual]", r.URL.Query(), &params.FilterGreaterOrEqual)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "filter[greaterOrEqual]", Err: err})
return
}
// ------------- Optional query parameter "filter[startsWith]" -------------
err = runtime.BindQueryParameter("form", true, false, "filter[startsWith]", r.URL.Query(), &params.FilterStartsWith)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "filter[startsWith]", Err: err})
return
}
// ------------- Optional query parameter "filter[endsWith]" -------------
err = runtime.BindQueryParameter("form", true, false, "filter[endsWith]", r.URL.Query(), &params.FilterEndsWith)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "filter[endsWith]", Err: err})
return
}
// ------------- Optional query parameter "sort" -------------
err = runtime.BindQueryParameter("form", true, false, "sort", r.URL.Query(), &params.Sort)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "sort", Err: err})
return
}
// ------------- Optional query parameter "include" -------------
err = runtime.BindQueryParameter("form", false, false, "include", r.URL.Query(), &params.Include)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "include", Err: err})
return
}
var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
siw.Handler.GetTracks(w, r, params)
})
for _, middleware := range siw.HandlerMiddlewares {
handler = middleware(handler)
}
handler.ServeHTTP(w, r.WithContext(ctx))
}
// GetTrack operation middleware
func (siw *ServerInterfaceWrapper) GetTrack(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
var err error
// ------------- Path parameter "trackId" -------------
var trackId string
err = runtime.BindStyledParameterWithLocation("simple", false, "trackId", runtime.ParamLocationPath, chi.URLParam(r, "trackId"), &trackId)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "trackId", Err: err})
return
}
ctx = context.WithValue(ctx, BearerAuthScopes, []string{})
// Parameter object where we will unmarshal all parameters from the context
var params GetTrackParams
// ------------- Optional query parameter "include" -------------
err = runtime.BindQueryParameter("form", false, false, "include", r.URL.Query(), &params.Include)
if err != nil {
siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "include", Err: err})
return
}
var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
siw.Handler.GetTrack(w, r, trackId, params)
})
for _, middleware := range siw.HandlerMiddlewares {
handler = middleware(handler)
}
handler.ServeHTTP(w, r.WithContext(ctx))
}
type UnescapedCookieParamError struct {
ParamName string
Err error
}
func (e *UnescapedCookieParamError) Error() string {
return fmt.Sprintf("error unescaping cookie parameter '%s'", e.ParamName)
}
func (e *UnescapedCookieParamError) Unwrap() error {
return e.Err
}
type UnmarshallingParamError struct {
ParamName string
Err error
}
func (e *UnmarshallingParamError) Error() string {
return fmt.Sprintf("Error unmarshalling parameter %s as JSON: %s", e.ParamName, e.Err.Error())
}
func (e *UnmarshallingParamError) Unwrap() error {
return e.Err
}
type RequiredParamError struct {
ParamName string
}
func (e *RequiredParamError) Error() string {
return fmt.Sprintf("Query argument %s is required, but not found", e.ParamName)
}
type RequiredHeaderError struct {
ParamName string
Err error
}
func (e *RequiredHeaderError) Error() string {
return fmt.Sprintf("Header parameter %s is required, but not found", e.ParamName)
}
func (e *RequiredHeaderError) Unwrap() error {
return e.Err
}
type InvalidParamFormatError struct {
ParamName string
Err error
}
func (e *InvalidParamFormatError) Error() string {
return fmt.Sprintf("Invalid format for parameter %s: %s", e.ParamName, e.Err.Error())
}
func (e *InvalidParamFormatError) Unwrap() error {
return e.Err
}
type TooManyValuesForParamError struct {
ParamName string
Count int
}
func (e *TooManyValuesForParamError) Error() string {
return fmt.Sprintf("Expected one value for %s, got %d", e.ParamName, e.Count)
}
// Handler creates http.Handler with routing matching OpenAPI spec.
func Handler(si ServerInterface) http.Handler {
return HandlerWithOptions(si, ChiServerOptions{})
}
type ChiServerOptions struct {
BaseURL string
BaseRouter chi.Router
Middlewares []MiddlewareFunc
ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}
// HandlerFromMux creates http.Handler with routing matching OpenAPI spec based on the provided mux.
func HandlerFromMux(si ServerInterface, r chi.Router) http.Handler {
return HandlerWithOptions(si, ChiServerOptions{
BaseRouter: r,
})
}
func HandlerFromMuxWithBaseURL(si ServerInterface, r chi.Router, baseURL string) http.Handler {
return HandlerWithOptions(si, ChiServerOptions{
BaseURL: baseURL,
BaseRouter: r,
})
}
// HandlerWithOptions creates http.Handler with additional options
func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handler {
r := options.BaseRouter
if r == nil {
r = chi.NewRouter()
}
if options.ErrorHandlerFunc == nil {
options.ErrorHandlerFunc = func(w http.ResponseWriter, r *http.Request, err error) {
http.Error(w, err.Error(), http.StatusBadRequest)
}
}
wrapper := ServerInterfaceWrapper{
Handler: si,
HandlerMiddlewares: options.Middlewares,
ErrorHandlerFunc: options.ErrorHandlerFunc,
}
r.Group(func(r chi.Router) {
r.Get(options.BaseURL+"/albums", wrapper.GetAlbums)
})
r.Group(func(r chi.Router) {
r.Get(options.BaseURL+"/albums/{albumId}", wrapper.GetAlbum)
})
r.Group(func(r chi.Router) {
r.Get(options.BaseURL+"/artists", wrapper.GetArtists)
})
r.Group(func(r chi.Router) {
r.Get(options.BaseURL+"/artists/{artistId}", wrapper.GetArtist)
})
r.Group(func(r chi.Router) {
r.Get(options.BaseURL+"/server", wrapper.GetServerInfo)
})
r.Group(func(r chi.Router) {
r.Get(options.BaseURL+"/tracks", wrapper.GetTracks)
})
r.Group(func(r chi.Router) {
r.Get(options.BaseURL+"/tracks/{trackId}", wrapper.GetTrack)
})
return r
}
type BadRequestJSONResponse ErrorList
type InternalServerErrorJSONResponse ErrorList
type NotAuthorizedJSONResponse ErrorList
type NotFoundJSONResponse ErrorList
type GetAlbumsRequestObject struct {
Params GetAlbumsParams
}
type GetAlbumsResponseObject interface {
VisitGetAlbumsResponse(w http.ResponseWriter) error
}
type GetAlbums200JSONResponse struct {
Data []Album `json:"data"`
Included *[]IncludedResource `json:"included,omitempty"`
Links PaginationLinks `json:"links"`
Meta *PaginationMeta `json:"meta,omitempty"`
}
func (response GetAlbums200JSONResponse) VisitGetAlbumsResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/vnd.api+json")
w.WriteHeader(200)
return json.NewEncoder(w).Encode(response)
}
type GetAlbums400JSONResponse struct{ BadRequestJSONResponse }
func (response GetAlbums400JSONResponse) VisitGetAlbumsResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/vnd.api+json")
w.WriteHeader(400)
return json.NewEncoder(w).Encode(response)
}
type GetAlbums403JSONResponse struct{ NotAuthorizedJSONResponse }
func (response GetAlbums403JSONResponse) VisitGetAlbumsResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/vnd.api+json")
w.WriteHeader(403)
return json.NewEncoder(w).Encode(response)
}
type GetAlbums500JSONResponse struct {
InternalServerErrorJSONResponse
}
func (response GetAlbums500JSONResponse) VisitGetAlbumsResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/vnd.api+json")
w.WriteHeader(500)
return json.NewEncoder(w).Encode(response)
}
type GetAlbumRequestObject struct {
AlbumId string `json:"albumId"`
Params GetAlbumParams
}
type GetAlbumResponseObject interface {
VisitGetAlbumResponse(w http.ResponseWriter) error
}
type GetAlbum200JSONResponse struct {
Data Album `json:"data"`
Included *[]IncludedResource `json:"included,omitempty"`
}
func (response GetAlbum200JSONResponse) VisitGetAlbumResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/vnd.api+json")
w.WriteHeader(200)
return json.NewEncoder(w).Encode(response)
}
type GetAlbum403JSONResponse struct{ NotAuthorizedJSONResponse }
func (response GetAlbum403JSONResponse) VisitGetAlbumResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/vnd.api+json")
w.WriteHeader(403)
return json.NewEncoder(w).Encode(response)
}
type GetAlbum404JSONResponse struct{ NotFoundJSONResponse }
func (response GetAlbum404JSONResponse) VisitGetAlbumResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/vnd.api+json")
w.WriteHeader(404)
return json.NewEncoder(w).Encode(response)
}
type GetAlbum500JSONResponse struct {
InternalServerErrorJSONResponse
}
func (response GetAlbum500JSONResponse) VisitGetAlbumResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/vnd.api+json")
w.WriteHeader(500)
return json.NewEncoder(w).Encode(response)
}
type GetArtistsRequestObject struct {
Params GetArtistsParams
}
type GetArtistsResponseObject interface {
VisitGetArtistsResponse(w http.ResponseWriter) error
}
type GetArtists200JSONResponse struct {
Data []Artist `json:"data"`
Links PaginationLinks `json:"links"`
Meta *PaginationMeta `json:"meta,omitempty"`
}
func (response GetArtists200JSONResponse) VisitGetArtistsResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/vnd.api+json")
w.WriteHeader(200)
return json.NewEncoder(w).Encode(response)
}
type GetArtists400JSONResponse struct{ BadRequestJSONResponse }
func (response GetArtists400JSONResponse) VisitGetArtistsResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/vnd.api+json")
w.WriteHeader(400)
return json.NewEncoder(w).Encode(response)
}
type GetArtists403JSONResponse struct{ NotAuthorizedJSONResponse }
func (response GetArtists403JSONResponse) VisitGetArtistsResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/vnd.api+json")
w.WriteHeader(403)
return json.NewEncoder(w).Encode(response)
}
type GetArtists500JSONResponse struct {
InternalServerErrorJSONResponse
}
func (response GetArtists500JSONResponse) VisitGetArtistsResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/vnd.api+json")
w.WriteHeader(500)
return json.NewEncoder(w).Encode(response)
}
type GetArtistRequestObject struct {
ArtistId string `json:"artistId"`
Params GetArtistParams
}
type GetArtistResponseObject interface {
VisitGetArtistResponse(w http.ResponseWriter) error
}
type GetArtist200JSONResponse struct {
Data Artist `json:"data"`
}
func (response GetArtist200JSONResponse) VisitGetArtistResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/vnd.api+json")
w.WriteHeader(200)
return json.NewEncoder(w).Encode(response)
}
type GetArtist403JSONResponse struct{ NotAuthorizedJSONResponse }
func (response GetArtist403JSONResponse) VisitGetArtistResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/vnd.api+json")
w.WriteHeader(403)
return json.NewEncoder(w).Encode(response)
}
type GetArtist404JSONResponse struct{ NotFoundJSONResponse }
func (response GetArtist404JSONResponse) VisitGetArtistResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/vnd.api+json")
w.WriteHeader(404)
return json.NewEncoder(w).Encode(response)
}
type GetArtist500JSONResponse struct {
InternalServerErrorJSONResponse
}
func (response GetArtist500JSONResponse) VisitGetArtistResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/vnd.api+json")
w.WriteHeader(500)
return json.NewEncoder(w).Encode(response)
}
type GetServerInfoRequestObject struct {
}
type GetServerInfoResponseObject interface {
VisitGetServerInfoResponse(w http.ResponseWriter) error
}
type GetServerInfo200JSONResponse struct {
Data ServerInfo `json:"data"`
}
func (response GetServerInfo200JSONResponse) VisitGetServerInfoResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/vnd.api+json")
w.WriteHeader(200)
return json.NewEncoder(w).Encode(response)
}
type GetServerInfo403JSONResponse struct{ NotAuthorizedJSONResponse }
func (response GetServerInfo403JSONResponse) VisitGetServerInfoResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/vnd.api+json")
w.WriteHeader(403)
return json.NewEncoder(w).Encode(response)
}
type GetServerInfo500JSONResponse struct {
InternalServerErrorJSONResponse
}
func (response GetServerInfo500JSONResponse) VisitGetServerInfoResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/vnd.api+json")
w.WriteHeader(500)
return json.NewEncoder(w).Encode(response)
}
type GetTracksRequestObject struct {
Params GetTracksParams
}
type GetTracksResponseObject interface {
VisitGetTracksResponse(w http.ResponseWriter) error
}
type GetTracks200JSONResponse struct {
Data []Track `json:"data"`
Included *[]IncludedResource `json:"included,omitempty"`
Links PaginationLinks `json:"links"`
Meta *PaginationMeta `json:"meta,omitempty"`
}
func (response GetTracks200JSONResponse) VisitGetTracksResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/vnd.api+json")
w.WriteHeader(200)
return json.NewEncoder(w).Encode(response)
}
type GetTracks400JSONResponse struct{ BadRequestJSONResponse }
func (response GetTracks400JSONResponse) VisitGetTracksResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/vnd.api+json")
w.WriteHeader(400)
return json.NewEncoder(w).Encode(response)
}
type GetTracks403JSONResponse struct{ NotAuthorizedJSONResponse }
func (response GetTracks403JSONResponse) VisitGetTracksResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/vnd.api+json")
w.WriteHeader(403)
return json.NewEncoder(w).Encode(response)
}
type GetTracks500JSONResponse struct {
InternalServerErrorJSONResponse
}
func (response GetTracks500JSONResponse) VisitGetTracksResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/vnd.api+json")
w.WriteHeader(500)
return json.NewEncoder(w).Encode(response)
}
type GetTrackRequestObject struct {
TrackId string `json:"trackId"`
Params GetTrackParams
}
type GetTrackResponseObject interface {
VisitGetTrackResponse(w http.ResponseWriter) error
}
type GetTrack200JSONResponse struct {
Data Track `json:"data"`
Included *[]IncludedResource `json:"included,omitempty"`
}
func (response GetTrack200JSONResponse) VisitGetTrackResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/vnd.api+json")
w.WriteHeader(200)
return json.NewEncoder(w).Encode(response)
}
type GetTrack403JSONResponse struct{ NotAuthorizedJSONResponse }
func (response GetTrack403JSONResponse) VisitGetTrackResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/vnd.api+json")
w.WriteHeader(403)
return json.NewEncoder(w).Encode(response)
}
type GetTrack404JSONResponse struct{ NotFoundJSONResponse }
func (response GetTrack404JSONResponse) VisitGetTrackResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/vnd.api+json")
w.WriteHeader(404)
return json.NewEncoder(w).Encode(response)
}
type GetTrack500JSONResponse struct {
InternalServerErrorJSONResponse
}
func (response GetTrack500JSONResponse) VisitGetTrackResponse(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/vnd.api+json")
w.WriteHeader(500)
return json.NewEncoder(w).Encode(response)
}
// StrictServerInterface represents all server handlers.
type StrictServerInterface interface {
// Retrieve a list of albums
// (GET /albums)
GetAlbums(ctx context.Context, request GetAlbumsRequestObject) (GetAlbumsResponseObject, error)
// Retrieve an individual album
// (GET /albums/{albumId})
GetAlbum(ctx context.Context, request GetAlbumRequestObject) (GetAlbumResponseObject, error)
// Retrieve a list of artists
// (GET /artists)
GetArtists(ctx context.Context, request GetArtistsRequestObject) (GetArtistsResponseObject, error)
// Retrieve an individual artist
// (GET /artists/{artistId})
GetArtist(ctx context.Context, request GetArtistRequestObject) (GetArtistResponseObject, error)
// Get server's global info
// (GET /server)
GetServerInfo(ctx context.Context, request GetServerInfoRequestObject) (GetServerInfoResponseObject, error)
// Retrieve a list of tracks
// (GET /tracks)
GetTracks(ctx context.Context, request GetTracksRequestObject) (GetTracksResponseObject, error)
// Retrieve an individual track
// (GET /tracks/{trackId})
GetTrack(ctx context.Context, request GetTrackRequestObject) (GetTrackResponseObject, error)
}
type StrictHandlerFunc = runtime.StrictHttpHandlerFunc
type StrictMiddlewareFunc = runtime.StrictHttpMiddlewareFunc
type StrictHTTPServerOptions struct {
RequestErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
ResponseErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}
func NewStrictHandler(ssi StrictServerInterface, middlewares []StrictMiddlewareFunc) ServerInterface {
return &strictHandler{ssi: ssi, middlewares: middlewares, options: StrictHTTPServerOptions{
RequestErrorHandlerFunc: func(w http.ResponseWriter, r *http.Request, err error) {
http.Error(w, err.Error(), http.StatusBadRequest)
},
ResponseErrorHandlerFunc: func(w http.ResponseWriter, r *http.Request, err error) {
http.Error(w, err.Error(), http.StatusInternalServerError)
},
}}
}
func NewStrictHandlerWithOptions(ssi StrictServerInterface, middlewares []StrictMiddlewareFunc, options StrictHTTPServerOptions) ServerInterface {
return &strictHandler{ssi: ssi, middlewares: middlewares, options: options}
}
type strictHandler struct {
ssi StrictServerInterface
middlewares []StrictMiddlewareFunc
options StrictHTTPServerOptions
}
// GetAlbums operation middleware
func (sh *strictHandler) GetAlbums(w http.ResponseWriter, r *http.Request, params GetAlbumsParams) {
var request GetAlbumsRequestObject
request.Params = params
handler := func(ctx context.Context, w http.ResponseWriter, r *http.Request, request interface{}) (interface{}, error) {
return sh.ssi.GetAlbums(ctx, request.(GetAlbumsRequestObject))
}
for _, middleware := range sh.middlewares {
handler = middleware(handler, "GetAlbums")
}
response, err := handler(r.Context(), w, r, request)
if err != nil {
sh.options.ResponseErrorHandlerFunc(w, r, err)
} else if validResponse, ok := response.(GetAlbumsResponseObject); ok {
if err := validResponse.VisitGetAlbumsResponse(w); err != nil {
sh.options.ResponseErrorHandlerFunc(w, r, err)
}
} else if response != nil {
sh.options.ResponseErrorHandlerFunc(w, r, fmt.Errorf("Unexpected response type: %T", response))
}
}
// GetAlbum operation middleware
func (sh *strictHandler) GetAlbum(w http.ResponseWriter, r *http.Request, albumId string, params GetAlbumParams) {
var request GetAlbumRequestObject
request.AlbumId = albumId
request.Params = params
handler := func(ctx context.Context, w http.ResponseWriter, r *http.Request, request interface{}) (interface{}, error) {
return sh.ssi.GetAlbum(ctx, request.(GetAlbumRequestObject))
}
for _, middleware := range sh.middlewares {
handler = middleware(handler, "GetAlbum")
}
response, err := handler(r.Context(), w, r, request)
if err != nil {
sh.options.ResponseErrorHandlerFunc(w, r, err)
} else if validResponse, ok := response.(GetAlbumResponseObject); ok {
if err := validResponse.VisitGetAlbumResponse(w); err != nil {
sh.options.ResponseErrorHandlerFunc(w, r, err)
}
} else if response != nil {
sh.options.ResponseErrorHandlerFunc(w, r, fmt.Errorf("Unexpected response type: %T", response))
}
}
// GetArtists operation middleware
func (sh *strictHandler) GetArtists(w http.ResponseWriter, r *http.Request, params GetArtistsParams) {
var request GetArtistsRequestObject
request.Params = params
handler := func(ctx context.Context, w http.ResponseWriter, r *http.Request, request interface{}) (interface{}, error) {
return sh.ssi.GetArtists(ctx, request.(GetArtistsRequestObject))
}
for _, middleware := range sh.middlewares {
handler = middleware(handler, "GetArtists")
}
response, err := handler(r.Context(), w, r, request)
if err != nil {
sh.options.ResponseErrorHandlerFunc(w, r, err)
} else if validResponse, ok := response.(GetArtistsResponseObject); ok {
if err := validResponse.VisitGetArtistsResponse(w); err != nil {
sh.options.ResponseErrorHandlerFunc(w, r, err)
}
} else if response != nil {
sh.options.ResponseErrorHandlerFunc(w, r, fmt.Errorf("Unexpected response type: %T", response))
}
}
// GetArtist operation middleware
func (sh *strictHandler) GetArtist(w http.ResponseWriter, r *http.Request, artistId string, params GetArtistParams) {
var request GetArtistRequestObject
request.ArtistId = artistId
request.Params = params
handler := func(ctx context.Context, w http.ResponseWriter, r *http.Request, request interface{}) (interface{}, error) {
return sh.ssi.GetArtist(ctx, request.(GetArtistRequestObject))
}
for _, middleware := range sh.middlewares {
handler = middleware(handler, "GetArtist")
}
response, err := handler(r.Context(), w, r, request)
if err != nil {
sh.options.ResponseErrorHandlerFunc(w, r, err)
} else if validResponse, ok := response.(GetArtistResponseObject); ok {
if err := validResponse.VisitGetArtistResponse(w); err != nil {
sh.options.ResponseErrorHandlerFunc(w, r, err)
}
} else if response != nil {
sh.options.ResponseErrorHandlerFunc(w, r, fmt.Errorf("Unexpected response type: %T", response))
}
}
// GetServerInfo operation middleware
func (sh *strictHandler) GetServerInfo(w http.ResponseWriter, r *http.Request) {
var request GetServerInfoRequestObject
handler := func(ctx context.Context, w http.ResponseWriter, r *http.Request, request interface{}) (interface{}, error) {
return sh.ssi.GetServerInfo(ctx, request.(GetServerInfoRequestObject))
}
for _, middleware := range sh.middlewares {
handler = middleware(handler, "GetServerInfo")
}
response, err := handler(r.Context(), w, r, request)
if err != nil {
sh.options.ResponseErrorHandlerFunc(w, r, err)
} else if validResponse, ok := response.(GetServerInfoResponseObject); ok {
if err := validResponse.VisitGetServerInfoResponse(w); err != nil {
sh.options.ResponseErrorHandlerFunc(w, r, err)
}
} else if response != nil {
sh.options.ResponseErrorHandlerFunc(w, r, fmt.Errorf("Unexpected response type: %T", response))
}
}
// GetTracks operation middleware
func (sh *strictHandler) GetTracks(w http.ResponseWriter, r *http.Request, params GetTracksParams) {
var request GetTracksRequestObject
request.Params = params
handler := func(ctx context.Context, w http.ResponseWriter, r *http.Request, request interface{}) (interface{}, error) {
return sh.ssi.GetTracks(ctx, request.(GetTracksRequestObject))
}
for _, middleware := range sh.middlewares {
handler = middleware(handler, "GetTracks")
}
response, err := handler(r.Context(), w, r, request)
if err != nil {
sh.options.ResponseErrorHandlerFunc(w, r, err)
} else if validResponse, ok := response.(GetTracksResponseObject); ok {
if err := validResponse.VisitGetTracksResponse(w); err != nil {
sh.options.ResponseErrorHandlerFunc(w, r, err)
}
} else if response != nil {
sh.options.ResponseErrorHandlerFunc(w, r, fmt.Errorf("Unexpected response type: %T", response))
}
}
// GetTrack operation middleware
func (sh *strictHandler) GetTrack(w http.ResponseWriter, r *http.Request, trackId string, params GetTrackParams) {
var request GetTrackRequestObject
request.TrackId = trackId
request.Params = params
handler := func(ctx context.Context, w http.ResponseWriter, r *http.Request, request interface{}) (interface{}, error) {
return sh.ssi.GetTrack(ctx, request.(GetTrackRequestObject))
}
for _, middleware := range sh.middlewares {
handler = middleware(handler, "GetTrack")
}
response, err := handler(r.Context(), w, r, request)
if err != nil {
sh.options.ResponseErrorHandlerFunc(w, r, err)
} else if validResponse, ok := response.(GetTrackResponseObject); ok {
if err := validResponse.VisitGetTrackResponse(w); err != nil {
sh.options.ResponseErrorHandlerFunc(w, r, err)
}
} else if response != nil {
sh.options.ResponseErrorHandlerFunc(w, r, fmt.Errorf("Unexpected response type: %T", response))
}
}
// Base64 encoded, gzipped, json marshaled Swagger object
var swaggerSpec = []string{
"H4sIAAAAAAAC/+w73W7bONavQ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PTmjH09h9QCh9wW7pM/rK/gLAWhoWOaL85+Jy9AgKKcnFcJZyl56TaRxROsUtYNds5MXiWT",
"VBat7XZ+SrhMpgXVBtT05emvz84un3XiRbRmt1EcLeqKKjqaPJ4cYbOrBEFLFh1HTyauTCqpyfGaTlvH",
"NHfzMPYA0CpOMysLmJO6kOwOwg8UPe2WaTsINNQZ29jsR3JG7F6b2x69v5nZHw3RzIruBVEP2I4G6s4j",
"7wu0N7HOROh4Tdd/CTACAmeDRuzrzQaurjeGhh4fHR00gfIxr32+k9uLsp7bbDSmXmM8gJTXvd9tiDZb",
"xSOr541ubPB5suYgENJ7UbPtSHmHsYqjX9wBhdhoDnLaGf1CkCe7QdaHoVZx9NcxhELDXZibVIWtt3Hs",
"0oc+2hNmFdeecHqH/59mq50+cW+XuDkMbK/JmP7sxswEjuRZD95O5Hmeo+4pu7bj8JDew963UdfsAa7V",
"yHf4voEL34Np8/rDjPWXo19GQflZtwewbkGYyNiCZRXl3micgbelwqBdN73i78H+e7C/72D/ZcR4/w77",
"zcRjf2W/kYBcS9NxWNM798OumFz3dg4KynsH45paKBp7dr+WcOxvxMeETv+Y8Y3FzlYx0/ZBdMj+Os/K",
"n+0oOzwcfJxXnb8++u+//6OJhSTvYEkKWroOSfMA70+cZAw7IlQtiYJSgbbXRczX3ms/t7d5Acbz8oMm",
"cy4TyrEJ5s63nRYdOl//11zfU6PvqdGD9EG8fX0JOVIzPfe9DzKYd3mH8W2kXbUwrSec3uH/O3KuK/+M",
"dmgfpLb5/XKv+vEukHp5pr+SzKu5Z19SI6R+c/22cjlnM6vuayWaaved8u21tQWXIzhDdg81U1qy6eJx",
"tLpe/S8AAP//4eMuGR1IAAA=",
}
// GetSwagger returns the content of the embedded swagger specification file
// or error if failed to decode
func decodeSpec() ([]byte, error) {
zipped, err := base64.StdEncoding.DecodeString(strings.Join(swaggerSpec, ""))
if err != nil {
return nil, fmt.Errorf("error base64 decoding spec: %s", err)
}
zr, err := gzip.NewReader(bytes.NewReader(zipped))
if err != nil {
return nil, fmt.Errorf("error decompressing spec: %s", err)
}
var buf bytes.Buffer
_, err = buf.ReadFrom(zr)
if err != nil {
return nil, fmt.Errorf("error decompressing spec: %s", err)
}
return buf.Bytes(), nil
}
var rawSpec = decodeSpecCached()
// a naive cached of a decoded swagger spec
func decodeSpecCached() func() ([]byte, error) {
data, err := decodeSpec()
return func() ([]byte, error) {
return data, err
}
}
// Constructs a synthetic filesystem for resolving external references when loading openapi specifications.
func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error) {
var res = make(map[string]func() ([]byte, error))
if len(pathToFile) > 0 {
res[pathToFile] = rawSpec
}
return res
}
// GetSwagger returns the Swagger specification corresponding to the generated code
// in this file. The external references of Swagger specification are resolved.
// The logic of resolving external references is tightly connected to "import-mapping" feature.
// Externally referenced files must be embedded in the corresponding golang packages.
// Urls can be supported but this task was out of the scope.
func GetSwagger() (swagger *openapi3.T, err error) {
var resolvePath = PathToRawSpec("")
loader := openapi3.NewLoader()
loader.IsExternalRefsAllowed = true
loader.ReadFromURIFunc = func(loader *openapi3.Loader, url *url.URL) ([]byte, error) {
var pathToFile = url.String()
pathToFile = path.Clean(pathToFile)
getSpec, ok := resolvePath[pathToFile]
if !ok {
err1 := fmt.Errorf("path not found: %s", pathToFile)
return nil, err1
}
return getSpec()
}
var specData []byte
specData, err = rawSpec()
if err != nil {
return
}
swagger, err = loader.LoadFromData(specData)
if err != nil {
return
}
return
}