Files
query-orchestration/api/queryService/api.gen.go
T
Michael McGuinness ed8cfbbee4 Merged in feature/collectorset (pull request #96)
Set Collector

* set
2025-03-10 13:00:57 +00:00

710 lines
26 KiB
Go

// Package queryservice provides primitives to interact with the openapi HTTP API.
//
// Code generated by github.com/oapi-codegen/oapi-codegen/v2 version 2.4.1 DO NOT EDIT.
package queryservice
import (
"bytes"
"compress/gzip"
"encoding/base64"
"fmt"
"net/http"
"net/url"
"path"
"strings"
"github.com/getkin/kin-openapi/openapi3"
"github.com/labstack/echo/v4"
"github.com/oapi-codegen/runtime"
openapi_types "github.com/oapi-codegen/runtime/types"
)
// Defines values for ClientStatus.
const (
INSYNC ClientStatus = "IN_SYNC"
NOTSYNCED ClientStatus = "NOT_SYNCED"
NOTSYNCING ClientStatus = "NOT_SYNCING"
)
// Defines values for ExportStatus.
const (
Completed ExportStatus = "completed"
Failed ExportStatus = "failed"
InProgress ExportStatus = "in_progress"
)
// Defines values for FieldFilterCondition.
const (
ClosedInterval FieldFilterCondition = "closed_interval"
Exclude FieldFilterCondition = "exclude"
GreaterThan FieldFilterCondition = "greater_than"
Include FieldFilterCondition = "include"
LeftClosedInterval FieldFilterCondition = "left_closed_interval"
LessThan FieldFilterCondition = "less_than"
OpenInterval FieldFilterCondition = "open_interval"
RightClosedInterval FieldFilterCondition = "right_closed_interval"
)
// Defines values for QueryType.
const (
CONTEXTFULL QueryType = "CONTEXT_FULL"
JSONEXTRACTOR QueryType = "JSON_EXTRACTOR"
)
// ClientCreate defines model for ClientCreate.
type ClientCreate struct {
// Name The client name
Name string `json:"name"`
}
// ClientStatus Specifies the status of a client.
type ClientStatus string
// ClientStatusBody defines model for ClientStatusBody.
type ClientStatusBody struct {
// ClientId The client id
ClientId openapi_types.UUID `json:"client_id"`
// Status Specifies the status of a client.
Status ClientStatus `json:"status"`
}
// ClientUpdate defines model for ClientUpdate.
type ClientUpdate struct {
// CanSync If the client is allowing active syncs
CanSync *bool `json:"can_sync,omitempty"`
// Name The client name
Name *string `json:"name,omitempty"`
}
// Collector Collector model.
type Collector struct {
// ActiveVersion The active version of the collector.
ActiveVersion int32 `json:"active_version"`
// ClientId The ID of the associated client.
ClientId openapi_types.UUID `json:"client_id"`
// Fields The fields in the collector.
Fields []CollectorField `json:"fields"`
// LatestVersion The latest version of the collector.
LatestVersion int32 `json:"latest_version"`
// MinimumCleanerVersion The minimum version for the document cleaner.
MinimumCleanerVersion int32 `json:"minimum_cleaner_version"`
// MinimumTextVersion The minimum version for the text parser.
MinimumTextVersion int32 `json:"minimum_text_version"`
}
// CollectorField The field properties for the collector.
type CollectorField struct {
// Name The output field name.
Name string `json:"name"`
// QueryId The query id that will populate the result.
QueryId openapi_types.UUID `json:"query_id"`
}
// CollectorSet Payload for updating a Collector.
type CollectorSet struct {
// ActiveVersion The active version of the collector.
ActiveVersion *int32 `json:"active_version,omitempty"`
// Fields The fields in the collector.
Fields *[]CollectorField `json:"fields,omitempty"`
// MinimumCleanerVersion The minimum version for the document cleaner.
MinimumCleanerVersion *int32 `json:"minimum_cleaner_version,omitempty"`
// MinimumTextVersion The minimum version for the text parser.
MinimumTextVersion *int32 `json:"minimum_text_version,omitempty"`
}
// DocClient defines model for DocClient.
type DocClient struct {
// CanSync If the client is allowing active syncs
CanSync bool `json:"can_sync"`
// Id The client id
Id openapi_types.UUID `json:"id"`
// Name The client name
Name string `json:"name"`
}
// Document defines model for Document.
type Document struct {
// Bucket The bucket containing the document
Bucket string `json:"bucket"`
// Id The document id
Id openapi_types.UUID `json:"id"`
// Key The path to the document
Key string `json:"key"`
}
// ExportDetails Payload for export trigger response.
type ExportDetails struct {
// ClientId The client id relative to the export.
ClientId openapi_types.UUID `json:"client_id"`
// OutputLocation The location in which the export zip file will be found.
OutputLocation *string `json:"output_location,omitempty"`
// Status The possible export states.
Status ExportStatus `json:"status"`
}
// ExportStatus The possible export states.
type ExportStatus string
// ExportTrigger Payload for triggering an export.
type ExportTrigger struct {
// FieldFilters Filter the scope based on field output values.
FieldFilters *[]FieldFilter `json:"field_filters,omitempty"`
// IngestionFilters Filter the scope based on ingestion parameters.
IngestionFilters *struct {
// EndDate The last date of ingestion.
EndDate *string `json:"end_date,omitempty"`
// StartDate This first date of ingestion.
StartDate *string `json:"start_date,omitempty"`
} `json:"ingestion_filters,omitempty"`
}
// FieldFilter Filtering a column
type FieldFilter struct {
// Condition The possible field filtering conditions.
Condition FieldFilterCondition `json:"condition"`
// FieldName The name of the field in question.
FieldName string `json:"field_name"`
// Values The values useful to the filter.
Values []string `json:"values"`
}
// FieldFilterCondition The possible field filtering conditions.
type FieldFilterCondition string
// IdMessage defines model for IdMessage.
type IdMessage struct {
// Id Unique identifier for entity.
Id openapi_types.UUID `json:"id"`
}
// ListDocuments The documents in the client.
type ListDocuments = []Document
// ListQueries defines model for ListQueries.
type ListQueries struct {
// Queries List of queries.
Queries []Query `json:"queries"`
}
// Query defines model for Query.
type Query struct {
// ActiveVersion The active version of the query.
ActiveVersion int32 `json:"active_version"`
// Config Configuration for the query.
Config *string `json:"config,omitempty"`
// Id Unique identifier for the query.
Id openapi_types.UUID `json:"id"`
// LatestVersion The latest version of the query.
LatestVersion int32 `json:"latest_version"`
// RequiredQueries List of required query IDs.
RequiredQueries *[]openapi_types.UUID `json:"required_queries,omitempty"`
// Type Specifies the type of the query.
Type QueryType `json:"type"`
}
// QueryCreate defines model for QueryCreate.
type QueryCreate struct {
// Config Configuration for the new query.
Config *string `json:"config,omitempty"`
// RequiredQueries List of required query IDs.
RequiredQueries *[]openapi_types.UUID `json:"required_queries,omitempty"`
// Type Specifies the type of the query.
Type QueryType `json:"type"`
}
// QueryTestRequest defines model for QueryTestRequest.
type QueryTestRequest struct {
// DocumentId ID of the document to test against.
DocumentId openapi_types.UUID `json:"document_id"`
// QueryVersion Version of the query to use for testing.
QueryVersion int32 `json:"query_version"`
}
// QueryTestResponse defines model for QueryTestResponse.
type QueryTestResponse struct {
// Value Result of the query test.
Value string `json:"value"`
}
// QueryType Specifies the type of the query.
type QueryType string
// QueryUpdate defines model for QueryUpdate.
type QueryUpdate struct {
// ActiveVersion Updated active version.
ActiveVersion *int32 `json:"active_version,omitempty"`
// Config Updated configuration for the query.
Config *string `json:"config,omitempty"`
// RequiredQueries Updated list of required query IDs.
RequiredQueries *[]openapi_types.UUID `json:"required_queries,omitempty"`
}
// CreateClientJSONRequestBody defines body for CreateClient for application/json ContentType.
type CreateClientJSONRequestBody = ClientCreate
// UpdateClientJSONRequestBody defines body for UpdateClient for application/json ContentType.
type UpdateClientJSONRequestBody = ClientUpdate
// SetCollectorByClientIdJSONRequestBody defines body for SetCollectorByClientId for application/json ContentType.
type SetCollectorByClientIdJSONRequestBody = CollectorSet
// TriggerExportJSONRequestBody defines body for TriggerExport for application/json ContentType.
type TriggerExportJSONRequestBody = ExportTrigger
// CreateQueryJSONRequestBody defines body for CreateQuery for application/json ContentType.
type CreateQueryJSONRequestBody = QueryCreate
// UpdateQueryJSONRequestBody defines body for UpdateQuery for application/json ContentType.
type UpdateQueryJSONRequestBody = QueryUpdate
// TestQueryJSONRequestBody defines body for TestQuery for application/json ContentType.
type TestQueryJSONRequestBody = QueryTestRequest
// ServerInterface represents all server handlers.
type ServerInterface interface {
// Create a new client
// (POST /client)
CreateClient(ctx echo.Context) error
// Get a client by ID
// (GET /client/{id})
GetClient(ctx echo.Context, id openapi_types.UUID) error
// Update a client
// (PATCH /client/{id})
UpdateClient(ctx echo.Context, id openapi_types.UUID) error
// Get a collector by client ID
// (GET /client/{id}/collector)
GetCollectorByClientId(ctx echo.Context, id openapi_types.UUID) error
// Set a collector
// (PATCH /client/{id}/collector)
SetCollectorByClientId(ctx echo.Context, id openapi_types.UUID) error
// List the documents for a client
// (GET /client/{id}/documents)
ListDocumentsByClientId(ctx echo.Context, id openapi_types.UUID) error
// Check export state.
// (GET /client/{id}/export)
ExportState(ctx echo.Context, id openapi_types.UUID) error
// Trigger an export
// (POST /client/{id}/export)
TriggerExport(ctx echo.Context, id openapi_types.UUID) error
// Get client sync status
// (GET /client/{id}/status)
GetStatusByClientId(ctx echo.Context, id openapi_types.UUID) error
// List queries
// (GET /query)
ListQueries(ctx echo.Context) error
// Create a new query
// (POST /query)
CreateQuery(ctx echo.Context) error
// Get a query by ID
// (GET /query/{id})
GetQuery(ctx echo.Context, id openapi_types.UUID) error
// Update a query
// (PATCH /query/{id})
UpdateQuery(ctx echo.Context, id openapi_types.UUID) error
// Test a query
// (POST /query/{id}/test)
TestQuery(ctx echo.Context, id openapi_types.UUID) error
}
// ServerInterfaceWrapper converts echo contexts to parameters.
type ServerInterfaceWrapper struct {
Handler ServerInterface
}
// CreateClient converts echo context to params.
func (w *ServerInterfaceWrapper) CreateClient(ctx echo.Context) error {
var err error
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.CreateClient(ctx)
return err
}
// GetClient converts echo context to params.
func (w *ServerInterfaceWrapper) GetClient(ctx echo.Context) error {
var err error
// ------------- Path parameter "id" -------------
var id openapi_types.UUID
err = runtime.BindStyledParameterWithOptions("simple", "id", ctx.Param("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true})
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err))
}
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.GetClient(ctx, id)
return err
}
// UpdateClient converts echo context to params.
func (w *ServerInterfaceWrapper) UpdateClient(ctx echo.Context) error {
var err error
// ------------- Path parameter "id" -------------
var id openapi_types.UUID
err = runtime.BindStyledParameterWithOptions("simple", "id", ctx.Param("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true})
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err))
}
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.UpdateClient(ctx, id)
return err
}
// GetCollectorByClientId converts echo context to params.
func (w *ServerInterfaceWrapper) GetCollectorByClientId(ctx echo.Context) error {
var err error
// ------------- Path parameter "id" -------------
var id openapi_types.UUID
err = runtime.BindStyledParameterWithOptions("simple", "id", ctx.Param("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true})
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err))
}
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.GetCollectorByClientId(ctx, id)
return err
}
// SetCollectorByClientId converts echo context to params.
func (w *ServerInterfaceWrapper) SetCollectorByClientId(ctx echo.Context) error {
var err error
// ------------- Path parameter "id" -------------
var id openapi_types.UUID
err = runtime.BindStyledParameterWithOptions("simple", "id", ctx.Param("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true})
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err))
}
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.SetCollectorByClientId(ctx, id)
return err
}
// ListDocumentsByClientId converts echo context to params.
func (w *ServerInterfaceWrapper) ListDocumentsByClientId(ctx echo.Context) error {
var err error
// ------------- Path parameter "id" -------------
var id openapi_types.UUID
err = runtime.BindStyledParameterWithOptions("simple", "id", ctx.Param("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true})
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err))
}
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.ListDocumentsByClientId(ctx, id)
return err
}
// ExportState converts echo context to params.
func (w *ServerInterfaceWrapper) ExportState(ctx echo.Context) error {
var err error
// ------------- Path parameter "id" -------------
var id openapi_types.UUID
err = runtime.BindStyledParameterWithOptions("simple", "id", ctx.Param("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true})
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err))
}
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.ExportState(ctx, id)
return err
}
// TriggerExport converts echo context to params.
func (w *ServerInterfaceWrapper) TriggerExport(ctx echo.Context) error {
var err error
// ------------- Path parameter "id" -------------
var id openapi_types.UUID
err = runtime.BindStyledParameterWithOptions("simple", "id", ctx.Param("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true})
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err))
}
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.TriggerExport(ctx, id)
return err
}
// GetStatusByClientId converts echo context to params.
func (w *ServerInterfaceWrapper) GetStatusByClientId(ctx echo.Context) error {
var err error
// ------------- Path parameter "id" -------------
var id openapi_types.UUID
err = runtime.BindStyledParameterWithOptions("simple", "id", ctx.Param("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true})
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err))
}
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.GetStatusByClientId(ctx, id)
return err
}
// ListQueries converts echo context to params.
func (w *ServerInterfaceWrapper) ListQueries(ctx echo.Context) error {
var err error
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.ListQueries(ctx)
return err
}
// CreateQuery converts echo context to params.
func (w *ServerInterfaceWrapper) CreateQuery(ctx echo.Context) error {
var err error
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.CreateQuery(ctx)
return err
}
// GetQuery converts echo context to params.
func (w *ServerInterfaceWrapper) GetQuery(ctx echo.Context) error {
var err error
// ------------- Path parameter "id" -------------
var id openapi_types.UUID
err = runtime.BindStyledParameterWithOptions("simple", "id", ctx.Param("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true})
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err))
}
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.GetQuery(ctx, id)
return err
}
// UpdateQuery converts echo context to params.
func (w *ServerInterfaceWrapper) UpdateQuery(ctx echo.Context) error {
var err error
// ------------- Path parameter "id" -------------
var id openapi_types.UUID
err = runtime.BindStyledParameterWithOptions("simple", "id", ctx.Param("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true})
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err))
}
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.UpdateQuery(ctx, id)
return err
}
// TestQuery converts echo context to params.
func (w *ServerInterfaceWrapper) TestQuery(ctx echo.Context) error {
var err error
// ------------- Path parameter "id" -------------
var id openapi_types.UUID
err = runtime.BindStyledParameterWithOptions("simple", "id", ctx.Param("id"), &id, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true})
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err))
}
// Invoke the callback with all the unmarshaled arguments
err = w.Handler.TestQuery(ctx, id)
return err
}
// This is a simple interface which specifies echo.Route addition functions which
// are present on both echo.Echo and echo.Group, since we want to allow using
// either of them for path registration
type EchoRouter interface {
CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
}
// RegisterHandlers adds each server route to the EchoRouter.
func RegisterHandlers(router EchoRouter, si ServerInterface) {
RegisterHandlersWithBaseURL(router, si, "")
}
// Registers handlers, and prepends BaseURL to the paths, so that the paths
// can be served under a prefix.
func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string) {
wrapper := ServerInterfaceWrapper{
Handler: si,
}
router.POST(baseURL+"/client", wrapper.CreateClient)
router.GET(baseURL+"/client/:id", wrapper.GetClient)
router.PATCH(baseURL+"/client/:id", wrapper.UpdateClient)
router.GET(baseURL+"/client/:id/collector", wrapper.GetCollectorByClientId)
router.PATCH(baseURL+"/client/:id/collector", wrapper.SetCollectorByClientId)
router.GET(baseURL+"/client/:id/documents", wrapper.ListDocumentsByClientId)
router.GET(baseURL+"/client/:id/export", wrapper.ExportState)
router.POST(baseURL+"/client/:id/export", wrapper.TriggerExport)
router.GET(baseURL+"/client/:id/status", wrapper.GetStatusByClientId)
router.GET(baseURL+"/query", wrapper.ListQueries)
router.POST(baseURL+"/query", wrapper.CreateQuery)
router.GET(baseURL+"/query/:id", wrapper.GetQuery)
router.PATCH(baseURL+"/query/:id", wrapper.UpdateQuery)
router.POST(baseURL+"/query/:id/test", wrapper.TestQuery)
}
// Base64 encoded, gzipped, json marshaled Swagger object
var swaggerSpec = []string{
"H4sIAAAAAAAC/+RbX2/juBH/KoTaR8PO3d6T3/aS7MLFNtkm3uKKa2DQ1NjmLU0qJOXEDfzdC/4RJVmU",
"rDh2bou+RRY5f38zHM4oLwkR60xw4Fol45dEkRWssf3zklHg+lIC1mCeMykykJqCfcvx2v6agiKSZpoK",
"noyT6QoQsfuQXTBI9DaDZJwoLSlfJrvdIJHwmFMJaTL+3VF5CKvE/A8gOtkNPPN7jXWummzuMyB0QUEh",
"vQKk7CokFgh75sNkkADP14bF5GZ2/6+by2SQ3NxO7Z/XV5WHyc3nig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VsaVK6xQ+15W4trg6nWcHab3yGc/ZnUK5wjrvaQyH3KP13o",
"ObkCOPqH3YhUh92vCMAwCPcx6H3VForF8l+3TqBJes64LCf4sbgMovcOzZjJfTBW7RBsULV/ObZ7RWQG",
"SvGZ53sG5j3oQpxS2cMhed/u9DMEZ3U22is4f+n6tkOBPmFs3teB0o2N/fBMq/2hA+FpYFJUkWXjaL6t",
"ZvhYfNb6UO8ToPXWV8fhGdQwir3ND/bmrGtNNRNckZwZJHtjzAZGZ4rZfbC4iUgrUi5XQL47mJBcSiOs",
"neHYj9qq85Q6PMrJEJwTEvXxYgQSbgFaYYXmAByFadNx+dtaozbLGlYg4JU+rpoqLXmeRB29Ek041dSW",
"UJXJZSaFyWJNp/p5m1PzTFm5Ptn7ka5A17X59EkrMa9uGVAdoNqP33La2yPTqy0nxVepvWow/5np+xRg",
"+x+2tqd4r8KJr0neFBUjve2qFL5EOGMqfywGHAfLcFYfwlRH2HaITCTVICmOn/XF0OfM53vBJuL6j/sa",
"nMLt9nx/DLoVzrY9qZqve3SUXO/t1Q0lN6I6TzatziB+pFzqen5n7iY9esO2ODVEzxGtJOfq7k5S6dcz",
"xYufjrZZ9+Q9pKB07a7aDJX+NU9ogf/ZTaNK6PboGZ09Yt/YMXL+P2PD6FWRNdLFCO+HAUY0mV8/A8ld",
"NrezQplz9587bXm9/mHVXqkMSp8dJtURaX+snJq/HzlG8tDUmtF/3v6m+tjObg/CzuwBuYkD7KsUaU7C",
"FApkMkhyyZJxstI6U+PRCGd06L/NHBKxHm1+SgxaPLd9ereFv5X7zhRSpIUv+VSJ1nrZuBv0JFM0eaqU",
"9hs/fYmV7aBAq9Gs6EurLJU8pZoP+lJxl5wKlfolZ/ew+28AAAD//9G30tr+NwAA",
}
// 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: %w", err)
}
zr, err := gzip.NewReader(bytes.NewReader(zipped))
if err != nil {
return nil, fmt.Errorf("error decompressing spec: %w", err)
}
var buf bytes.Buffer
_, err = buf.ReadFrom(zr)
if err != nil {
return nil, fmt.Errorf("error decompressing spec: %w", 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) {
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) {
resolvePath := PathToRawSpec("")
loader := openapi3.NewLoader()
loader.IsExternalRefsAllowed = true
loader.ReadFromURIFunc = func(loader *openapi3.Loader, url *url.URL) ([]byte, error) {
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
}