rest

package
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2026 License: GPL-3.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULTLIMIT = 20

DEFAULTLIMIT is the default API limit

View Source
const MAXRADIUS = 100 * 1000.0

MAXRADIUS is the maximum point search radius

Variables

View Source
var MAXLIMIT = 1_000

MAXLIMIT is the API limit maximum

View Source
var ParameterComponents = oa.ParametersMap{
	"adm0IsoParam": &pref{
		Value: &param{
			Name:        "adm0_iso",
			In:          "query",
			Description: `Search by country 2 letter ISO 3166 code`,
			Schema:      newSRVal("string", "", nil),
		},
	},
	"adm0NameParam": &pref{
		Value: &param{
			Name:        "adm0_name",
			In:          "query",
			Description: `Search by country name`,
			Schema:      newSRVal("string", "", nil),
		},
	},
	"adm1IsoParam": &pref{
		Value: &param{
			Name:        "adm1_iso",
			In:          "query",
			Description: `Search by state/province/division ISO 3166-2 code`,
			Schema:      newSRVal("string", "", nil),
		},
	},
	"adm1NameParam": &pref{
		Value: &param{
			Name:        "adm1_name",
			In:          "query",
			Description: `Search by state/province/division name`,
			Schema:      newSRVal("string", "", nil),
		},
	},
	"afterParam": &pref{
		Value: &param{
			Name:        "after",
			In:          "query",
			Description: `Pagination cursor value. This should be treated as an opaque value created by the server and returned as the link to the next result page, which may be empty. For historical reasons, this is based on the integer record ID values, but that should not be assumed to be the case in the future.`,
			Schema:      newSRVal("integer", "int32", nil),
		},
	},
	"bboxParam": &pref{
		Value: &param{
			Name:        "bbox",
			In:          "query",
			Description: `Geographic search using a bounding box, with coordinates in (min_lon, min_lat, max_lon, max_lat) order as a comma separated string`,
			Schema:      newSRVal("string", "", nil),
		},
	},
	"cityNameParam": &pref{
		Value: &param{
			Name:        "city_name",
			In:          "query",
			Description: `Search by city name`,
			Schema:      newSRVal("string", "", nil),
		},
	},
	"feedParam": &pref{
		Value: &param{
			Name:        "feed_onestop_id",
			In:          "query",
			Description: `Search for records in this feed`,
			Schema:      newSRVal("string", "", nil),
		},
	},
	"formatParam": &pref{
		Value: &param{
			Name:        "format",
			In:          "query",
			Description: `Response format`,
			Schema:      newSRVal("string", "", []any{"json", "geojson", "geojsonl"}),
		},
	},
	"idParam": &pref{
		Value: &param{
			Name:        "id",
			In:          "query",
			Description: `Search for a specific internal ID`,
			Schema:      newSRVal("integer", "int32", nil),
		},
	},
	"includeAlertsParam": &pref{
		Value: &param{
			Name:        "include_alerts",
			In:          "query",
			Description: `Include alerts from GTFS Realtime feeds`,
			Schema:      newSRVal("string", "", []any{"true", "false"}),
		},
	},
	"latParam": &pref{
		Value: &param{
			Name:        "lat",
			In:          "query",
			Description: `Latitude`,
			Schema:      newSRVal("number", "", nil),
		},
	},
	"licenseCommercialUseAllowedParam": &pref{
		Value: &param{
			Name:        "license_commercial_use_allowed",
			In:          "query",
			Description: `Filter entities by feed license 'commercial_use_allowed' value. Please see Source Feed concept for details on license values. 'exclude_no' is equivalent to 'yes' and 'unknown'.`,
			Schema:      newSRVal("string", "", []any{"yes", "no", "unknown", "exclude_no"}),
		},
	},
	"licenseCreateDerivedProductParam": &pref{
		Value: &param{
			Name:        "license_create_derived_product",
			In:          "query",
			Description: `Filter entities by feed license 'create_derived_product' value. Please see Source Feed concept for details on license values. 'exclude_no' is equivalent to 'yes' and 'unknown'.`,
			Schema:      newSRVal("string", "", []any{"yes", "no", "unknown", "exclude_no"}),
		},
	},
	"licenseRedistributionAllowedParam": &pref{
		Value: &param{
			Name:        "license_redistribution_allowed",
			In:          "query",
			Description: `Filter entities by feed license 'redistribution_allowed' value. Please see Source Feed concept for details on license values. 'exclude_no' is equivalent to 'yes' and 'unknown'.`,
			Schema:      newSRVal("string", "", []any{"yes", "no", "unknown", "exclude_no"}),
		},
	},
	"licenseShareAlikeOptionalParam": &pref{
		Value: &param{
			Name:        "license_share_alike_optional",
			In:          "query",
			Description: `Filter entities by feed license 'share_alike_optional' value. Please see Source Feed concept for details on license values. 'exclude_no' is equivalent to 'yes' and 'unknown'.`,
			Schema:      newSRVal("string", "", []any{"yes", "no", "unknown", "exclude_no"}),
		},
	},
	"licenseUseWithoutAttributionParam": &pref{
		Value: &param{
			Name:        "license_use_without_attribution",
			In:          "query",
			Description: `Filter entities by feed license 'use_without_attribution' value. Please see Source Feed concept for details on license values. 'exclude_no' is equivalent to 'yes' and 'unknown'.`,
			Schema:      newSRVal("string", "", []any{"yes", "no", "unknown", "exclude_no"}),
		},
	},
	"limitParam": &pref{
		Value: &param{
			Name:        "limit",
			In:          "query",
			Description: `Maximum number of records to return`,
			Schema:      newSRVal("integer", "int32", nil),
		},
	},
	"lonParam": &pref{
		Value: &param{
			Name:        "lon",
			In:          "query",
			Description: `Longitude`,
			Schema:      newSRVal("number", "", nil),
		},
	},
	"onestopParam": &pref{
		Value: &param{
			Name:        "onestop_id",
			In:          "query",
			Description: `Search for a specific Onestop ID`,
			Schema:      newSRVal("string", "", nil),
		},
	},
	"radiusParam": &pref{
		Value: &param{
			Name:        "radius",
			In:          "query",
			Description: `Search radius (meters); requires lat and lon`,
			Schema:      newSRVal("number", "", nil),
		},
	},
	"relativeDateParam": &pref{
		Value: &param{
			Name:        "relative_date",
			In:          "query",
			Description: `Search for departures on a relative date label, e.g. TODAY, TOMORROW, TUESDAY, NEXT_WEDNESDAY`,
			Schema:      newSRVal("string", "", []any{"TODAY", "YESTERDAY", "TOMORROW", "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY", "SUNDAY", "NEXT_MONDAY", "NEXT_TUESDAY", "NEXT_WEDNESDAY", "NEXT_THURSDAY", "NEXT_FRIDAY", "NEXT_SATURDAY", "NEXT_SUNDAY"}),
		},
	},
	"searchParam": &pref{
		Value: &param{
			Name:        "search",
			In:          "query",
			Description: `Full text search`,
			Schema:      newSRVal("string", "", nil),
		},
	},
	"sha1Param": &pref{
		Value: &param{
			Name:        "feed_version_sha1",
			In:          "query",
			Description: `Search for records in this feed version`,
			Schema:      newSRVal("string", "", nil),
		},
	},
	"includeGeometryParam": &pref{
		Value: &param{
			Name:        "include_geometry",
			In:          "query",
			Description: `Include geometry in response`,
			Schema:      newSRVal("string", "", []any{"true", "false"}),
		},
	},
	"includeStopsParam": &pref{
		Value: &param{
			Name:        "include_stops",
			In:          "query",
			Description: `Include stops in response`,
			Schema:      newSRVal("string", "", []any{"true", "false"}),
		},
	},
	"includeRoutesParam": &pref{
		Value: &param{
			Name:        "include_routes",
			In:          "query",
			Description: `Include routes that serve this stop`,
			Schema:      newSRVal("string", "", []any{"true", "false"}),
		},
	},
}

RestHandlersList contains all REST API handlers in logical order

Functions

func GenerateOpenAPI added in v1.3.0

func GenerateOpenAPI(restPrefix string, opts ...SchemaOption) (*oa.T, error)

func NewAgencyEntityHandler added in v1.4.0

func NewAgencyEntityHandler(graphqlHandler http.Handler) http.HandlerFunc

NewAgencyEntityHandler serves one agency. Reads {agency_key}, {format}.

func NewAgencyIndexHandler added in v1.4.0

func NewAgencyIndexHandler(graphqlHandler http.Handler) http.HandlerFunc

NewAgencyIndexHandler serves the agency index. Reads {format}.

func NewFeedDownloadRtHandler added in v1.4.0

func NewFeedDownloadRtHandler(graphqlHandler http.Handler) http.HandlerFunc

NewFeedDownloadRtHandler serves the latest GTFS Realtime message for a feed. Reads {feed_key}, {rt_type}, {format}.

func NewFeedEntityHandler added in v1.4.0

func NewFeedEntityHandler(graphqlHandler http.Handler) http.HandlerFunc

NewFeedEntityHandler serves one feed. Reads {feed_key}, {format}.

func NewFeedIndexHandler added in v1.4.0

func NewFeedIndexHandler(graphqlHandler http.Handler) http.HandlerFunc

NewFeedIndexHandler serves the feed index. Reads {format}.

func NewFeedVersionDownloadHandler added in v1.4.0

func NewFeedVersionDownloadHandler(graphqlHandler http.Handler) http.HandlerFunc

NewFeedVersionDownloadHandler serves one feed version file, when its license allows redistribution and the caller is within quota. Reads {feed_version_key}.

Authorizes nobody. Mount it behind tl_download_fv_historic, the role the generated document advertises for this endpoint.

func NewFeedVersionDownloadLatestHandler added in v1.4.0

func NewFeedVersionDownloadLatestHandler(graphqlHandler http.Handler) http.HandlerFunc

NewFeedVersionDownloadLatestHandler redirects to the latest feed version file for a feed, when its license allows redistribution. Reads {feed_key}.

Authorizes nobody. Mount it behind tl_download_fv_current, the role the generated document advertises for this endpoint.

func NewFeedVersionEntityHandler added in v1.4.0

func NewFeedVersionEntityHandler(graphqlHandler http.Handler) http.HandlerFunc

NewFeedVersionEntityHandler serves one feed version. Reads {feed_version_key}, {format}.

func NewFeedVersionExportHandler added in v1.4.0

func NewFeedVersionExportHandler(graphqlHandler http.Handler) http.HandlerFunc

NewFeedVersionExportHandler builds a filtered feed version export from a JSON request body.

Authorizes nobody, and accepts any method. Mount it for POST only and behind tl_export_feed_versions, the role the generated document advertises for this endpoint.

func NewFeedVersionIndexHandler added in v1.4.0

func NewFeedVersionIndexHandler(graphqlHandler http.Handler) http.HandlerFunc

NewFeedVersionIndexHandler serves the feed version index. Reads {feed_key}, {format}.

func NewOpenAPIHandler added in v1.4.0

func NewOpenAPIHandler(opts ...SchemaOption) http.Handler

NewOpenAPIHandler returns a handler serving the REST OpenAPI document, with servers[0].url built from mountPrefix so documented paths resolve against it. Exported for callers mounting the REST server outside this package.

The document is regenerated per request, which is fine for the example server this package wires up. Callers serving it under load should generate once at startup with GenerateOpenAPI and serve the bytes themselves.

func NewOperatorEntityHandler added in v1.4.0

func NewOperatorEntityHandler(graphqlHandler http.Handler) http.HandlerFunc

NewOperatorEntityHandler serves one operator. Reads {operator_key}, {format}.

func NewOperatorIndexHandler added in v1.4.0

func NewOperatorIndexHandler(graphqlHandler http.Handler) http.HandlerFunc

NewOperatorIndexHandler serves the operator index. Reads {format}.

func NewRouteEntityHandler added in v1.4.0

func NewRouteEntityHandler(graphqlHandler http.Handler) http.HandlerFunc

NewRouteEntityHandler serves one route. Reads {route_key}, {format}.

func NewRouteIndexHandler added in v1.4.0

func NewRouteIndexHandler(graphqlHandler http.Handler) http.HandlerFunc

NewRouteIndexHandler serves the route index. Reads {agency_key}, {format}.

func NewServer

func NewServer(graphqlHandler http.Handler) (http.Handler, error)

NewServer mounts every REST endpoint on one router.

This is the default mounting, for the library's own server command and its tests. It applies no authorization: the download and export endpoints are served to anyone who asks, so anything serving real traffic mounts the handler constructors itself and gates them.

func NewStopDepartureHandler added in v1.4.0

func NewStopDepartureHandler(graphqlHandler http.Handler) http.HandlerFunc

NewStopDepartureHandler serves departures for one stop. Reads {stop_key}.

func NewStopEntityHandler added in v1.4.0

func NewStopEntityHandler(graphqlHandler http.Handler) http.HandlerFunc

NewStopEntityHandler serves one stop. Reads {stop_key}, {format}.

func NewStopIndexHandler added in v1.4.0

func NewStopIndexHandler(graphqlHandler http.Handler) http.HandlerFunc

NewStopIndexHandler serves the stop index. Reads {format}.

func NewTripEntityHandler added in v1.4.0

func NewTripEntityHandler(graphqlHandler http.Handler) http.HandlerFunc

NewTripEntityHandler serves one trip. Reads {route_key}, {id}, {format} — the trip parameter is {id}, not {trip_key}.

func NewTripIndexHandler added in v1.4.0

func NewTripIndexHandler(graphqlHandler http.Handler) http.HandlerFunc

NewTripIndexHandler serves the trip index. Reads {route_key}, {format}.

func ServeFeedVersion added in v1.4.0

func ServeFeedVersion(ctx context.Context, w http.ResponseWriter, storage string, d FeedVersionDownload) error

ServeFeedVersion writes the feed version file, redirecting to a signed URL when the store supports one.

It writes an error response itself before returning a non-nil error, so a caller should log the error rather than answer again.

func WriteJsonError added in v1.4.0

func WriteJsonError(w http.ResponseWriter, msg string, statusCode int)

WriteJsonError writes an error response in the shape every endpoint in this package uses. Exported so a caller composing its own handlers over the exported request helpers answers failures the same way.

Types

type AgencyKeyRequest added in v1.3.0

type AgencyKeyRequest struct {
	AgencyRequest
}

func (AgencyKeyRequest) RequestInfo added in v1.3.0

func (r AgencyKeyRequest) RequestInfo() RequestInfo

type AgencyRequest

type AgencyRequest struct {
	ID              int       `json:"id,string"`
	AgencyKey       string    `json:"agency_key"`
	AgencyID        string    `json:"agency_id"`
	AgencyName      string    `json:"agency_name"`
	OnestopID       string    `json:"onestop_id"`
	FeedVersionSHA1 string    `json:"feed_version_sha1"`
	FeedOnestopID   string    `json:"feed_onestop_id"`
	Search          string    `json:"search"`
	Lon             float64   `json:"lon,string"`
	Lat             float64   `json:"lat,string"`
	Bbox            *restBbox `json:"bbox"`
	Radius          float64   `json:"radius,string"`
	Adm0Name        string    `json:"adm0_name"`
	Adm0Iso         string    `json:"adm0_iso"`
	Adm1Name        string    `json:"adm1_name"`
	Adm1Iso         string    `json:"adm1_iso"`
	CityName        string    `json:"city_name"`
	IncludeAlerts   bool      `json:"include_alerts,string"`
	IncludeRoutes   bool      `json:"include_routes,string"`
	LicenseFilter
	WithCursor
}

AgencyRequest holds options for an Agency request

func (AgencyRequest) Query

func (r AgencyRequest) Query(ctx context.Context) (string, map[string]interface{})

Query returns a GraphQL query string and variables.

func (AgencyRequest) RequestInfo added in v1.3.0

func (r AgencyRequest) RequestInfo() RequestInfo

func (AgencyRequest) ResponseKey

func (r AgencyRequest) ResponseKey() string

ResponseKey returns the GraphQL response entity key.

type ExportTransforms added in v1.3.0

type ExportTransforms struct {
	// ID prefix for namespacing
	Prefix string `json:"prefix,omitempty"`
	// Files to apply prefix to (default: all applicable files)
	PrefixFiles []string `json:"prefix_files,omitempty"`
	// Normalize timezones (e.g., US/Pacific -> America/Los_Angeles)
	NormalizeTimezones bool `json:"normalize_timezones,omitempty"`
	// Simplify shapes with this tolerance value
	SimplifyShapes *float64 `json:"simplify_shapes,omitempty"`
	// Use basic route types (convert extended to primitive)
	UseBasicRouteTypes bool `json:"use_basic_route_types,omitempty"`
	// Entity value overrides (filename.entity_id.field = value)
	SetValues map[string]string `json:"set_values,omitempty"`
	// Sort all CSV rows before zipping ("asc" or "desc"). Omit for no sort.
	StandardizedSort string `json:"standardized_sort,omitempty"`
	// Override the columns used for the sort; otherwise per-file defaults apply.
	StandardizedSortColumns []string `json:"standardized_sort_columns,omitempty"`
}

ExportTransforms defines available transformations

type FeedDownloadLatestFeedVersionRequest added in v1.3.0

type FeedDownloadLatestFeedVersionRequest struct {
}

Currently this exists only for OpenAPI documentation

func (FeedDownloadLatestFeedVersionRequest) Query added in v1.3.0

func (r FeedDownloadLatestFeedVersionRequest) Query(ctx context.Context) (string, map[string]interface{})

Query returns a GraphQL query string and variables.

func (FeedDownloadLatestFeedVersionRequest) RequestInfo added in v1.3.0

type FeedDownloadRtRequest added in v1.3.0

type FeedDownloadRtRequest struct {
}

Currently this exists only for OpenAPI documentation

func (FeedDownloadRtRequest) Query added in v1.3.0

func (r FeedDownloadRtRequest) Query(ctx context.Context) (string, map[string]interface{})

Query returns a GraphQL query string and variables.

func (FeedDownloadRtRequest) RequestInfo added in v1.3.0

func (r FeedDownloadRtRequest) RequestInfo() RequestInfo

type FeedKeyRequest added in v1.3.0

type FeedKeyRequest struct {
	FeedRequest
}

func (FeedKeyRequest) RequestInfo added in v1.3.0

func (r FeedKeyRequest) RequestInfo() RequestInfo

type FeedRequest

type FeedRequest struct {
	FeedKey          string    `json:"feed_key"`
	ID               int       `json:"id,string"`
	OnestopID        string    `json:"onestop_id"`
	Spec             string    `json:"spec"`
	Search           string    `json:"search"`
	FetchError       string    `json:"fetch_error"`
	TagKey           string    `json:"tag_key"`
	TagValue         string    `json:"tag_value"`
	URL              string    `json:"url"`
	URLType          string    `json:"url_type"`
	URLCaseSensitive bool      `json:"url_case_sensitive"`
	Lon              float64   `json:"lon,string"`
	Lat              float64   `json:"lat,string"`
	Radius           float64   `json:"radius,string"`
	Bbox             *restBbox `json:"bbox"`
	LicenseFilter
	WithCursor
}

FeedRequest holds options for a Feed request

func (FeedRequest) ProcessGeoJSON added in v1.3.0

func (r FeedRequest) ProcessGeoJSON(ctx context.Context, response map[string]interface{}) error

ProcessGeoJSON .

func (FeedRequest) Query

func (r FeedRequest) Query(ctx context.Context) (string, map[string]interface{})

Query returns a GraphQL query string and variables.

func (FeedRequest) RequestInfo added in v1.3.0

func (r FeedRequest) RequestInfo() RequestInfo

func (FeedRequest) ResponseKey added in v1.3.0

func (r FeedRequest) ResponseKey() string

ResponseKey .

type FeedVersionDownload added in v1.4.0

type FeedVersionDownload struct {
	FeedOnestopID         string
	FeedVersionSHA1       string
	RedistributionAllowed bool
	// IsLatestFeedVersion records that this was resolved as a feed's current
	// version rather than requested by key. Download quotas are scoped on it.
	IsLatestFeedVersion bool
}

FeedVersionDownload identifies one feed version file and says whether its feed's license permits redistributing it.

Zero values mean the lookup matched nothing: either the key names no feed version, or the caller may not see it. Redistribution is reported, not enforced.

func LookupFeedVersionDownload added in v1.4.0

func LookupFeedVersionDownload(ctx context.Context, graphqlHandler http.Handler, key string) (FeedVersionDownload, error)

LookupFeedVersionDownload resolves an integer id or a sha1 to the feed version file it names.

func LookupLatestFeedVersionDownload added in v1.4.0

func LookupLatestFeedVersionDownload(ctx context.Context, graphqlHandler http.Handler, feedKey string) (FeedVersionDownload, error)

LookupLatestFeedVersionDownload resolves an integer id or a feed Onestop ID to that feed's current version.

A feed with no versions is not an error: RT-only feeds have none, and the redistribution answer is still meaningful for them.

type FeedVersionDownloadRequest added in v1.3.0

type FeedVersionDownloadRequest struct {
}

Currently this exists only for OpenAPI documentation

func (FeedVersionDownloadRequest) Query added in v1.3.0

func (r FeedVersionDownloadRequest) Query(ctx context.Context) (string, map[string]interface{})

Query returns a GraphQL query string and variables.

func (FeedVersionDownloadRequest) RequestInfo added in v1.3.0

func (r FeedVersionDownloadRequest) RequestInfo() RequestInfo

type FeedVersionExportOpenAPIRequest added in v1.3.0

type FeedVersionExportOpenAPIRequest struct{}

FeedVersionExportOpenAPIRequest defines OpenAPI schema for export endpoint

func (FeedVersionExportOpenAPIRequest) RequestInfo added in v1.3.0

type FeedVersionExportRequest added in v1.3.0

type FeedVersionExportRequest struct {
	// Feed version IDs or SHA1 hashes to export
	FeedVersionKeys []string `json:"feed_version_keys"`
	FeedVersionIDs  []int    `json:"-"`
	// Output format (default: gtfs_zip)
	Format string `json:"format,omitempty"`
	// Transformation options
	Transforms *ExportTransforms `json:"transforms,omitempty"`
}

FeedVersionExportRequest defines the export request structure

func CheckFeedVersionExportRequest added in v1.3.0

func CheckFeedVersionExportRequest(ctx context.Context, req *FeedVersionExportRequest, graphqlHandler http.Handler) (*FeedVersionExportRequest, error)

type FeedVersionExporter added in v1.3.0

type FeedVersionExporter struct {
	// contains filtered or unexported fields
}

FeedVersionExporter handles exporting feed versions with transformations

func NewFeedVersionExporter added in v1.3.0

func NewFeedVersionExporter(cfg *model.Config) *FeedVersionExporter

NewFeedVersionExporter creates a new feed version exporter

func (*FeedVersionExporter) Export added in v1.3.0

func (e *FeedVersionExporter) Export(ctx context.Context, fvids []int, transforms *ExportTransforms, writer adapters.Writer) (*copier.Result, error)

Export performs the feed version export with optional transformations

type FeedVersionKeyRequest added in v1.3.0

type FeedVersionKeyRequest struct {
	FeedVersionRequest
}

func (FeedVersionKeyRequest) RequestInfo added in v1.3.0

func (r FeedVersionKeyRequest) RequestInfo() RequestInfo

type FeedVersionRequest

type FeedVersionRequest struct {
	FeedVersionKey  string    `json:"feed_version_key"`
	FeedKey         string    `json:"feed_key"`
	ID              int       `json:"id,string"`
	FeedID          int       `json:"feed_id,string"`
	FeedOnestopID   string    `json:"feed_onestop_id"`
	Sha1            string    `json:"sha1"`
	Sha1Dir         string    `json:"sha1_dir"`
	FetchedBefore   string    `json:"fetched_before"`
	FetchedAfter    string    `json:"fetched_after"`
	CoversStartDate string    `json:"covers_start_date"`
	CoversEndDate   string    `json:"covers_end_date"`
	Lon             float64   `json:"lon,string"`
	Lat             float64   `json:"lat,string"`
	Radius          float64   `json:"radius,string"`
	Bbox            *restBbox `json:"bbox"`
	WithCursor
}

FeedVersionRequest holds options for a Feed Version request

func (FeedVersionRequest) Query

func (r FeedVersionRequest) Query(ctx context.Context) (string, map[string]interface{})

Query returns a GraphQL query string and variables.

func (FeedVersionRequest) RequestInfo added in v1.3.0

func (r FeedVersionRequest) RequestInfo() RequestInfo

func (FeedVersionRequest) ResponseKey added in v1.3.0

func (r FeedVersionRequest) ResponseKey() string

ResponseKey .

type LicenseFilter added in v1.3.0

type LicenseFilter struct {
	LicenseCommercialUseAllowed  string `json:"license_commercial_use_allowed"`
	LicenseShareAlikeOptional    string `json:"license_share_alike_optional"`
	LicenseCreateDerivedProduct  string `json:"license_create_derived_product"`
	LicenseRedistributionAllowed string `json:"license_redistribution_allowed"`
	LicenseUseWithoutAttribution string `json:"license_use_without_attribution"`
}

type OnestopIdEntityRedirectRequest added in v1.3.0

type OnestopIdEntityRedirectRequest struct {
}

func (OnestopIdEntityRedirectRequest) RequestInfo added in v1.3.0

func (handler OnestopIdEntityRedirectRequest) RequestInfo() RequestInfo

func (*OnestopIdEntityRedirectRequest) ServeHTTP added in v1.3.0

Query returns a GraphQL query string and variables.

type OperatorKeyRequest added in v1.3.0

type OperatorKeyRequest struct {
	OperatorRequest
}

func (OperatorKeyRequest) RequestInfo added in v1.3.0

func (r OperatorKeyRequest) RequestInfo() RequestInfo

type OperatorRequest

type OperatorRequest struct {
	OperatorKey   string    `json:"operator_key"`
	ID            int       `json:"id,string"`
	OnestopID     string    `json:"onestop_id"`
	FeedOnestopID string    `json:"feed_onestop_id"`
	Search        string    `json:"search"`
	TagKey        string    `json:"tag_key"`
	TagValue      string    `json:"tag_value"`
	Lon           float64   `json:"lon,string"`
	Lat           float64   `json:"lat,string"`
	Bbox          *restBbox `json:"bbox"`
	Radius        float64   `json:"radius,string"`
	Adm0Name      string    `json:"adm0_name"`
	Adm0Iso       string    `json:"adm0_iso"`
	Adm1Name      string    `json:"adm1_name"`
	Adm1Iso       string    `json:"adm1_iso"`
	CityName      string    `json:"city_name"`
	IncludeAlerts bool      `json:"include_alerts,string"`
	LicenseFilter
	WithCursor
}

OperatorRequest holds options for an Operator request

func (OperatorRequest) Query

func (r OperatorRequest) Query(ctx context.Context) (string, map[string]interface{})

Query returns a GraphQL query string and variables.

func (OperatorRequest) RequestInfo added in v1.3.0

func (r OperatorRequest) RequestInfo() RequestInfo

func (OperatorRequest) ResponseKey

func (r OperatorRequest) ResponseKey() string

ResponseKey returns the GraphQL response entity key.

type ParsedDocstring added in v1.3.0

type ParsedDocstring struct {
	Text         string
	Type         string
	ExternalDocs []ParsedUrl
	Examples     []string
	Enum         []string
	Hide         bool
}

func ParseDocstring added in v1.3.0

func ParseDocstring(v string) ParsedDocstring

type ParsedUrl added in v1.3.0

type ParsedUrl struct {
	Text string
	URL  string
}

type RequestAltPath added in v1.3.0

type RequestAltPath struct {
	Method  string `json:"method"`
	Path    string `json:"path"`
	Summary string `json:"summary"`
}

type RequestInfo added in v1.3.0

type RequestInfo struct {
	Path        string
	Description string
	Get         *RequestOperation
	Post        *RequestOperation
}

type RequestOperation added in v1.3.0

type RequestOperation struct {
	Operation *oa.Operation
	Query     string
}

type RestHandlers added in v1.3.0

type RestHandlers interface {
	RequestInfo() RequestInfo
}

type RouteKeyRequest added in v1.3.0

type RouteKeyRequest struct {
	RouteRequest
}

func (RouteKeyRequest) RequestInfo added in v1.3.0

func (r RouteKeyRequest) RequestInfo() RequestInfo

type RouteRequest

type RouteRequest struct {
	ID                  int       `json:"id,string"`
	RouteKey            string    `json:"route_key"`
	AgencyKey           string    `json:"agency_key"`
	RouteID             string    `json:"route_id"`
	RouteType           string    `json:"route_type"`
	RouteTypes          string    `json:"route_types"`
	OnestopID           string    `json:"onestop_id"`
	OperatorOnestopID   string    `json:"operator_onestop_id"`
	ServesStopOnestopID string    `json:"serves_stop_onestop_id"`
	Format              string    `json:"format"`
	Search              string    `json:"search"`
	AgencyID            int       `json:"agency_id,string"`
	FeedVersionSHA1     string    `json:"feed_version_sha1"`
	FeedOnestopID       string    `json:"feed_onestop_id"`
	Lon                 float64   `json:"lon,string"`
	Lat                 float64   `json:"lat,string"`
	Radius              float64   `json:"radius,string"`
	Bbox                *restBbox `json:"bbox"`
	IncludeGeometry     bool      `json:"include_geometry,string"`
	IncludeAlerts       bool      `json:"include_alerts,string"`
	IncludeStops        bool      `json:"include_stops,string"`
	LicenseFilter
	WithCursor
}

RouteRequest holds options for a Route request

func (RouteRequest) Query

func (r RouteRequest) Query(ctx context.Context) (string, map[string]interface{})

Query returns a GraphQL query string and variables.

func (RouteRequest) RequestInfo added in v1.3.0

func (r RouteRequest) RequestInfo() RequestInfo

func (RouteRequest) ResponseKey

func (r RouteRequest) ResponseKey() string

ResponseKey returns the GraphQL response entity key.

type SchemaConfig added in v1.3.0

type SchemaConfig struct {
	Components     *oa.Components
	GlobalSecurity *oa.SecurityRequirements
}

SchemaConfig holds configuration options for schema generation

type SchemaOption added in v1.3.0

type SchemaOption func(*SchemaConfig)

SchemaOption is a function that modifies schema configuration

func WithComponents added in v1.3.0

func WithComponents(components *oa.Components) SchemaOption

WithComponents adds custom components to the schema

func WithSecurity added in v1.3.0

func WithSecurity(security *oa.SecurityRequirements) SchemaOption

WithSecurity adds global security requirements to all operations

type StopDepartureRequest added in v1.3.0

type StopDepartureRequest struct {
	StopKey          string `json:"stop_key"`
	ID               int    `json:"id,string"`
	StopID           string `json:"stop_id"`
	FeedOnestopID    string `json:"feed_onestop_id"`
	OnestopID        string `json:"onestop_id"`
	Next             int    `json:"next,string"`
	ServiceDate      string `json:"service_date"`
	Date             string `json:"date"`
	RelativeDate     string `json:"relative_date"`
	StartTime        string `json:"start_time"`
	EndTime          string `json:"end_time"`
	IncludeGeometry  bool   `json:"include_geometry,string"`
	IncludeAlerts    bool   `json:"include_alerts,string"`
	UseServiceWindow *bool  `json:"use_service_window,string"`
	WithCursor
}

StopDepartureRequest holds options for a /stops/_/departures request

func (StopDepartureRequest) IncludeNext added in v1.3.0

func (r StopDepartureRequest) IncludeNext() bool

IncludeNext

func (StopDepartureRequest) Query added in v1.3.0

func (r StopDepartureRequest) Query(ctx context.Context) (string, map[string]interface{})

Query returns a GraphQL query string and variables.

func (StopDepartureRequest) RequestInfo added in v1.3.0

func (r StopDepartureRequest) RequestInfo() RequestInfo

func (StopDepartureRequest) ResponseKey added in v1.3.0

func (r StopDepartureRequest) ResponseKey() string

ResponseKey returns the GraphQL response entity key.

type StopEntityRequest added in v1.3.0

type StopEntityRequest struct {
	StopRequest
}

func (StopEntityRequest) RequestInfo added in v1.3.0

func (r StopEntityRequest) RequestInfo() RequestInfo

type StopRequest

type StopRequest struct {
	ID                 int       `json:"id,string"`
	StopKey            string    `json:"stop_key"`
	StopID             string    `json:"stop_id"`
	OnestopID          string    `json:"onestop_id"`
	FeedVersionSHA1    string    `json:"feed_version_sha1"`
	FeedOnestopID      string    `json:"feed_onestop_id"`
	Search             string    `json:"search"`
	Bbox               *restBbox `json:"bbox"`
	Lon                float64   `json:"lon,string"`
	Lat                float64   `json:"lat,string"`
	Radius             float64   `json:"radius,string"`
	Format             string    `json:"format"`
	ServedByOnestopIds string    `json:"served_by_onestop_ids"`
	ServedByRouteType  *int      `json:"served_by_route_type,string"`
	ServedByRouteTypes string    `json:"served_by_route_types"`
	LocationType       *int      `json:"location_type,string"`
	IncludeAlerts      bool      `json:"include_alerts,string"`
	IncludeRoutes      bool      `json:"include_routes,string"`
	LicenseFilter
	WithCursor
}

StopRequest holds options for a /stops request

func (StopRequest) Query

func (r StopRequest) Query(ctx context.Context) (string, map[string]any)

Query returns a GraphQL query string and variables.

func (StopRequest) RequestInfo added in v1.3.0

func (r StopRequest) RequestInfo() RequestInfo

func (StopRequest) ResponseKey

func (r StopRequest) ResponseKey() string

ResponseKey returns the GraphQL response entity key.

type TripEntityRequest added in v1.3.0

type TripEntityRequest struct {
	TripRequest
}

func (TripEntityRequest) RequestInfo added in v1.3.0

func (r TripEntityRequest) RequestInfo() RequestInfo

type TripRequest

type TripRequest struct {
	ID               int    `json:"id,string"`
	TripID           string `json:"trip_id"`
	RouteKey         string `json:"route_key"`
	RouteID          int    `json:"route_id,string"`
	RouteOnestopID   string `json:"route_onestop_id"`
	FeedOnestopID    string `json:"feed_onestop_id"`
	FeedVersionSHA1  string `json:"feed_version_sha1"`
	ServiceDate      string `json:"service_date"`
	RelativeDate     string `json:"relative_date"`
	IncludeGeometry  bool   `json:"include_geometry,string"`
	IncludeStopTimes bool   `json:"include_stop_times,string"`
	IncludeAlerts    bool   `json:"include_alerts,string"`
	Format           string
	LicenseFilter
	WithCursor
}

TripRequest holds options for a /trips request

func (TripRequest) ProcessGeoJSON

func (r TripRequest) ProcessGeoJSON(ctx context.Context, response map[string]interface{}) error

ProcessGeoJSON .

func (TripRequest) Query

func (r TripRequest) Query(ctx context.Context) (string, map[string]interface{})

Query returns a GraphQL query string and variables.

func (TripRequest) RequestInfo added in v1.3.0

func (r TripRequest) RequestInfo() RequestInfo

func (TripRequest) ResponseKey

func (r TripRequest) ResponseKey() string

ResponseKey .

type WithCursor added in v1.3.0

type WithCursor struct {
	Limit int `json:"limit,string"`
	After int `json:"after,string"`
}

func (WithCursor) CheckAfter added in v1.3.0

func (w WithCursor) CheckAfter() int

func (WithCursor) CheckLimit added in v1.3.0

func (w WithCursor) CheckLimit() int

Directories

Path Synopsis
Package oatype builds OpenAPI schemas for GraphQL types.
Package oatype builds OpenAPI schemas for GraphQL types.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL