* internal/engine/ooapi: auto-generated API client * feat: introduce the callers abstraction * feat: implement API caching on disk * feat: implement cloneWithToken when we require login * feat: implement login * fix: do not cache all APIs * feat: start making space for more tests * feat: implement caching policy * feat: write tests for caching layer * feat: add integration tests and fix some minor issues * feat: write much more unit tests * feat: add some more easy unit tests * feat: add tests that use a local server While there, make sure many fields we care about are OK. * doc: write basic documentation * fix: tweak sentence * doc: improve ooapi documentation * doc(ooapi): other documentation improvements * fix(ooapi): remove caching for most APIs We discussed this topic yesterday with @FedericoCeratto. The only place where we want LRU caching is MeasurementMeta. * feat(ooapi): improve handling of errors during login This was also discussed yesterday with @FedericoCeratto * fix(swaggerdiff_test.go): temporarily disable Before I work on this, I need to tend onto other tasks. * fix(ootest): add one more test case We're going towards 100% coverage of this package, as it ought to be. * feat(ooapi): test cases for when the probe clock is off * fix(ooapi): change test to have 100% unittest coverage * feat: sync server and client APIs definition Companion PR: https://github.com/ooni/api/pull/218 * fix(ooapi): start testing again against API * fix(ooapi): only generate each file once * chore: set version to 3.7.0-alpha While there, make sure we don't always skip a currently failing riseupvpn test, and slightly clarify the readme. * fix(kvstore): less scoped error message
64 lines
1.9 KiB
Go
64 lines
1.9 KiB
Go
// Package openapi contains data structures for Swagger v2.0.
|
|
//
|
|
// We use these data structures to compare the API specification we
|
|
// have here with the one of the server.
|
|
package openapi
|
|
|
|
// Schema is the schema of a specific parameter or
|
|
// or the schema used by the response body
|
|
type Schema struct {
|
|
Properties map[string]*Schema `json:"properties,omitempty"`
|
|
Items *Schema `json:"items,omitempty"`
|
|
Type string `json:"type"`
|
|
}
|
|
|
|
// Parameter describes an input parameter, which could be in the
|
|
// URL path, in the query string, or in the request body
|
|
type Parameter struct {
|
|
In string `json:"in"`
|
|
Name string `json:"name"`
|
|
Required bool `json:"required,omitempty"`
|
|
Schema *Schema `json:"schema,omitempty"`
|
|
Type string `json:"type,omitempty"`
|
|
}
|
|
|
|
// Body describes a response body
|
|
type Body struct {
|
|
Description interface{} `json:"description,omitempty"`
|
|
Schema *Schema `json:"schema"`
|
|
}
|
|
|
|
// Responses describes the possible responses
|
|
type Responses struct {
|
|
Successful Body `json:"200"`
|
|
}
|
|
|
|
// RoundTrip describes an HTTP round trip with a given method and path
|
|
type RoundTrip struct {
|
|
Consumes []string `json:"consumes,omitempty"`
|
|
Produces []string `json:"produces,omitempty"`
|
|
Parameters []*Parameter `json:"parameters,omitempty"`
|
|
Responses *Responses `json:"responses,omitempty"`
|
|
}
|
|
|
|
// Path describes a path served by the API
|
|
type Path struct {
|
|
Get *RoundTrip `json:"get,omitempty"`
|
|
Post *RoundTrip `json:"post,omitempty"`
|
|
}
|
|
|
|
// API contains info about the API
|
|
type API struct {
|
|
Title string `json:"title"`
|
|
Version string `json:"version"`
|
|
}
|
|
|
|
// Swagger is the toplevel structure
|
|
type Swagger struct {
|
|
Swagger string `json:"swagger"`
|
|
Info API `json:"info"`
|
|
Host string `json:"host"`
|
|
BasePath string `json:"basePath"`
|
|
Schemes []string `json:"schemes"`
|
|
Paths map[string]*Path `json:"paths"`
|
|
}
|