Documentation ¶
Index ¶
- Constants
- Variables
- func AddOperationToPathItem(item *oapi_spec.PathItem, method string, operation *oapi_spec.Operation)
- func CloneOperation(op *spec.Operation) (*spec.Operation, error)
- func ConvertHeadersToMap(headers []*Header) map[string]string
- func CopyPathItemWithNewOperation(item *oapi_spec.PathItem, method string, operation *oapi_spec.Operation) *oapi_spec.PathItem
- func GetOperationFromPathItem(item *oapi_spec.PathItem, method string) *oapi_spec.Operation
- func GetPathAndQuery(fullPath string) (path, query string)
- func LoadAndValidateRawJSONSpecV3(spec []byte) (*oapi_spec.T, error)
- func LoadAndValidateRawJSONSpecV3FromV2(spec []byte) (*oapi_spec.T, error)
- func MergePathItems(dst, src *oapi_spec.PathItem) *oapi_spec.PathItem
- func NewAPIKeySecuritySchemeInHeader(name string) *spec.SecurityScheme
- func NewAPIKeySecuritySchemeInQuery(name string) *spec.SecurityScheme
- func NewBasicAuthSecurityScheme() *spec.SecurityScheme
- func NewOAuth2SecurityScheme(scopes []string) *spec.SecurityScheme
- type APIDiff
- type ApprovedSpec
- type ApprovedSpecReview
- type ApprovedSpecReviewPathItem
- type Common
- type DiffParams
- type DiffType
- type HTTPInteractionData
- type Header
- type LearningParametrizedPaths
- type LearningSpec
- type OASVersion
- type OAuth2Claims
- type OperationGenerator
- type OperationGeneratorConfig
- type PathParam
- type ProvidedSpec
- type Request
- type Response
- type ReviewPathItem
- type Spec
- func (s *Spec) ApplyApprovedReview(approvedReviews *ApprovedSpecReview, version OASVersion) error
- func (s *Spec) CreateSuggestedReview() *SuggestedSpecReview
- func (s *Spec) DiffTelemetry(telemetry *Telemetry, specSource SpecSource) (*APIDiff, error)
- func (s *Spec) GenerateOASJson(version OASVersion) ([]byte, error)
- func (s *Spec) GenerateOASYaml(version OASVersion) ([]byte, error)
- func (s *Spec) GetPathID(path string, specSource SpecSource) (string, error)
- func (s *Spec) HasApprovedSpec() bool
- func (s *Spec) HasProvidedSpec() bool
- func (s *Spec) LearnTelemetry(telemetry *Telemetry) error
- func (s *Spec) LoadProvidedSpec(providedSpec []byte, pathToPathID map[string]string) error
- func (s *Spec) SpecInfoClone() (*Spec, error)
- func (s *Spec) UnsetApprovedSpec()
- func (s *Spec) UnsetProvidedSpec()
- type SpecInfo
- type SpecSource
- type SuggestedSpecReview
- type SuggestedSpecReviewPathItem
- type Telemetry
- type TestOperation
- func (op *TestOperation) Deprecated() *TestOperation
- func (op *TestOperation) WithParameter(param *oapi_spec.Parameter) *TestOperation
- func (op *TestOperation) WithRequestBody(requestBody *oapi_spec.RequestBody) *TestOperation
- func (op *TestOperation) WithResponse(status int, response *oapi_spec.Response) *TestOperation
- func (op *TestOperation) WithSecurityRequirement(securityRequirement oapi_spec.SecurityRequirement) *TestOperation
- type TestPathItem
- type TestResponse
- type TestResponses
- type TestSpec
Constants ¶
View Source
const ( NoConflict = iota PreferType1 PreferType2 ConflictUnresolved )
View Source
const ( BasicAuthSecuritySchemeKey = "BasicAuth" APIKeyAuthSecuritySchemeKey = "ApiKeyAuth" OAuth2SecuritySchemeKey = "OAuth2" BearerAuthSecuritySchemeKey = "BearerAuth" BearerAuthPrefix = "Bearer " BasicAuthPrefix = "Basic " AccessTokenParamKey = "access_token" )
Variables ¶
View Source
var ( ErrUnknownSpecVersion = errors.New("unknown spec version") ErrUnsupportedSpecVersion = errors.New("unsupported spec version") )
Sentinel errors for spec version issues.
View Source
var APIKeyNames = map[string]bool{ "key": true, "api_key": true, }
APIKeyNames is set of names of headers or query params defining API keys. This should be runtime configurable, of course. Note: keys should be lowercase.
Functions ¶
func AddOperationToPathItem ¶
func ConvertHeadersToMap ¶
func GetPathAndQuery ¶
example: for "/example-path?param=value" returns "/example-path", "param=value"
func LoadAndValidateRawJSONSpecV3 ¶ added in v0.1.0
func LoadAndValidateRawJSONSpecV3FromV2 ¶ added in v0.1.0
func NewAPIKeySecuritySchemeInHeader ¶ added in v0.1.0
func NewAPIKeySecuritySchemeInHeader(name string) *spec.SecurityScheme
func NewAPIKeySecuritySchemeInQuery ¶ added in v0.1.0
func NewAPIKeySecuritySchemeInQuery(name string) *spec.SecurityScheme
func NewBasicAuthSecurityScheme ¶ added in v0.1.0
func NewBasicAuthSecurityScheme() *spec.SecurityScheme
func NewOAuth2SecurityScheme ¶ added in v0.1.0
func NewOAuth2SecurityScheme(scopes []string) *spec.SecurityScheme
Types ¶
type ApprovedSpec ¶
type ApprovedSpec struct { PathItems map[string]*oapi_spec.PathItem SecuritySchemes oapi_spec.SecuritySchemes SpecVersion OASVersion }
func (*ApprovedSpec) Clone ¶
func (a *ApprovedSpec) Clone() (*ApprovedSpec, error)
func (*ApprovedSpec) GetPathItem ¶
func (a *ApprovedSpec) GetPathItem(path string) *oapi_spec.PathItem
func (*ApprovedSpec) GetSpecVersion ¶ added in v0.1.0
func (a *ApprovedSpec) GetSpecVersion() OASVersion
type ApprovedSpecReview ¶
type ApprovedSpecReview struct { PathItemsReview []*ApprovedSpecReviewPathItem PathToPathItem map[string]*oapi_spec.PathItem }
type ApprovedSpecReviewPathItem ¶
type ApprovedSpecReviewPathItem struct { ReviewPathItem PathUUID string }
type DiffParams ¶
type DiffParams struct {
// contains filtered or unexported fields
}
type HTTPInteractionData ¶
type LearningSpec ¶
type LearningSpec struct { // map parameterized path into path item PathItems map[string]*openapi3.PathItem SecuritySchemes openapi3.SecuritySchemes }
func (*LearningSpec) AddPathItem ¶
func (l *LearningSpec) AddPathItem(path string, pathItem *openapi3.PathItem)
func (*LearningSpec) GetPathItem ¶
func (l *LearningSpec) GetPathItem(path string) *openapi3.PathItem
type OASVersion ¶ added in v0.1.0
type OASVersion int64
const ( Unknown OASVersion = iota OASv2 OASv3 )
func GetJSONSpecVersion ¶ added in v0.1.0
func GetJSONSpecVersion(jsonSpec []byte) (OASVersion, error)
func LoadAndValidateRawJSONSpec ¶ added in v0.1.0
func LoadAndValidateRawJSONSpec(spec []byte) (*openapi3.T, OASVersion, error)
func (OASVersion) String ¶ added in v0.1.0
func (o OASVersion) String() string
type OAuth2Claims ¶
type OAuth2Claims struct { Scope string `json:"scope"` jwt.RegisteredClaims }
type OperationGenerator ¶
type OperationGenerator struct { ResponseHeadersToIgnore map[string]struct{} RequestHeadersToIgnore map[string]struct{} }
func CreateTestNewOperationGenerator ¶
func CreateTestNewOperationGenerator() *OperationGenerator
func NewOperationGenerator ¶
func NewOperationGenerator(config OperationGeneratorConfig) *OperationGenerator
func (*OperationGenerator) GenerateSpecOperation ¶
func (o *OperationGenerator) GenerateSpecOperation(data *HTTPInteractionData, securitySchemes spec.SecuritySchemes) (*spec.Operation, error)
Note: SecuritySchemes might be updated.
type ProvidedSpec ¶
type ProvidedSpec struct { Doc *openapi3.T OriginalSpecVersion OASVersion }
func (*ProvidedSpec) GetBasePath ¶ added in v0.1.0
func (p *ProvidedSpec) GetBasePath() string
func (*ProvidedSpec) GetPathItem ¶
func (p *ProvidedSpec) GetPathItem(path string) *openapi3.PathItem
func (*ProvidedSpec) GetSpecVersion ¶ added in v0.1.0
func (p *ProvidedSpec) GetSpecVersion() OASVersion
type ReviewPathItem ¶
type Spec ¶
type Spec struct { SpecInfo OpGenerator *OperationGenerator // contains filtered or unexported fields }
func CreateDefaultSpec ¶
func CreateDefaultSpec(host string, port string, config OperationGeneratorConfig) *Spec
func (*Spec) ApplyApprovedReview ¶
func (s *Spec) ApplyApprovedReview(approvedReviews *ApprovedSpecReview, version OASVersion) error
func (*Spec) CreateSuggestedReview ¶
func (s *Spec) CreateSuggestedReview() *SuggestedSpecReview
CreateSuggestedReview group all paths that have suspect parameter (with a certain template), into one path which is parameterized, and then add this path params to the spec.
func (*Spec) DiffTelemetry ¶
func (s *Spec) DiffTelemetry(telemetry *Telemetry, specSource SpecSource) (*APIDiff, error)
func (*Spec) GenerateOASJson ¶
func (s *Spec) GenerateOASJson(version OASVersion) ([]byte, error)
func (*Spec) GenerateOASYaml ¶
func (s *Spec) GenerateOASYaml(version OASVersion) ([]byte, error)
func (*Spec) GetPathID ¶ added in v0.2.0
func (s *Spec) GetPathID(path string, specSource SpecSource) (string, error)
func (*Spec) HasApprovedSpec ¶
func (*Spec) HasProvidedSpec ¶
func (*Spec) LearnTelemetry ¶
func (*Spec) LoadProvidedSpec ¶
func (*Spec) SpecInfoClone ¶
func (*Spec) UnsetApprovedSpec ¶
func (s *Spec) UnsetApprovedSpec()
func (*Spec) UnsetProvidedSpec ¶
func (s *Spec) UnsetProvidedSpec()
type SpecInfo ¶
type SpecInfo struct { // Host of the spec Host string Port string // Spec ID ID uuid.UUID // Provided Spec ProvidedSpec *ProvidedSpec // Merged & approved state (can be generated into spec YAML) ApprovedSpec *ApprovedSpec // Upon learning, this will be updated (not the ApprovedSpec field) LearningSpec *LearningSpec ApprovedPathTrie pathtrie.PathTrie ProvidedPathTrie pathtrie.PathTrie }
type SpecSource ¶ added in v0.2.0
type SpecSource string
const ( SpecSourceReconstructed SpecSource = "RECONSTRUCTED" SpecSourceProvided SpecSource = "PROVIDED" )
type SuggestedSpecReview ¶
type SuggestedSpecReview struct { PathItemsReview []*SuggestedSpecReviewPathItem PathToPathItem map[string]*oapi_spec.PathItem }
type SuggestedSpecReviewPathItem ¶
type SuggestedSpecReviewPathItem struct {
ReviewPathItem
}
type Telemetry ¶
type Telemetry struct { DestinationAddress string `json:"destinationAddress,omitempty"` DestinationNamespace string `json:"destinationNamespace,omitempty"` Request *Request `json:"request,omitempty"` RequestID string `json:"requestID,omitempty"` Response *Response `json:"response,omitempty"` Scheme string `json:"scheme,omitempty"` SourceAddress string `json:"sourceAddress,omitempty"` }
type TestOperation ¶
func NewOperation ¶
func NewOperation(t *testing.T, data *HTTPInteractionData) *TestOperation
func (*TestOperation) Deprecated ¶
func (op *TestOperation) Deprecated() *TestOperation
func (*TestOperation) WithParameter ¶ added in v0.1.0
func (op *TestOperation) WithParameter(param *oapi_spec.Parameter) *TestOperation
func (*TestOperation) WithRequestBody ¶ added in v0.1.0
func (op *TestOperation) WithRequestBody(requestBody *oapi_spec.RequestBody) *TestOperation
func (*TestOperation) WithResponse ¶ added in v0.1.0
func (op *TestOperation) WithResponse(status int, response *oapi_spec.Response) *TestOperation
func (*TestOperation) WithSecurityRequirement ¶ added in v0.1.0
func (op *TestOperation) WithSecurityRequirement(securityRequirement oapi_spec.SecurityRequirement) *TestOperation
type TestPathItem ¶
func NewTestPathItem ¶
func NewTestPathItem() *TestPathItem
func (*TestPathItem) WithOperation ¶
func (t *TestPathItem) WithOperation(method string, op *oapi_spec.Operation) *TestPathItem
func (*TestPathItem) WithPathParams ¶
func (t *TestPathItem) WithPathParams(name string, schema *oapi_spec.Schema) *TestPathItem
type TestResponse ¶ added in v0.1.0
func (*TestResponse) WithHeader ¶ added in v0.1.0
func (r *TestResponse) WithHeader(name string, schema *oapi_spec.Schema) *TestResponse
func (*TestResponse) WithJSONSchema ¶ added in v0.1.0
func (r *TestResponse) WithJSONSchema(schema *oapi_spec.Schema) *TestResponse
type TestResponses ¶ added in v0.1.0
func (*TestResponses) WithResponse ¶ added in v0.1.0
func (r *TestResponses) WithResponse(code string, response *oapi_spec.Response) *TestResponses
Source Files ¶
Click to show internal directories.
Click to hide internal directories.