discovery

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package discovery reads Google's Discovery Document — the format they publish for their own REST APIs, and which no OpenAPI parser understands.

It is worth a dialect of its own because it is not one API: Google serves a discovery document for over three hundred services — Drive, Sheets, Calendar, Gmail, YouTube, Search Console, Analytics — all at a predictable address, all in the same shape. Written once, every one of them becomes reachable without a line of code per API.

What it is NOT good for: an API whose surface is huge. Drive has 64 methods, YouTube 83, Gmail 79 — publishing them whole gives a model dozens of tools it will never call, and a wrong option to pick among them. Use `--include-paths` to say what this connector is actually for.

Index

Constants

View Source
const DefaultDepth = 2

DefaultDepth is how far `$ref` chains are followed. Two levels covers the shape of a request (its fields, and the fields of the objects it holds) without dragging in the whole type graph.

Variables

This section is empty.

Functions

func Operations

func Operations(ctx context.Context, doc *spec.Document, o Options) ([]core.Operation, error)

Operations translates the whole document.

Types

type Options

type Options struct {
	BaseURL        string // beats the document's own baseUrl
	Auth           auth.Applier
	Client         *http.Client
	IncludePaths   []*regexp.Regexp
	ExcludePaths   []*regexp.Regexp
	IncludeMethods []string
	ExcludeMethods []string
	Headers        map[string]string
	Depth          int // how far $ref chains are expanded; see DefaultDepth
}

Options are decisions made by whoever starts the server, not by the document.

Jump to

Keyboard shortcuts

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