mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-07 04:20:14 +00:00
Moved index into its own package
removed non generic code used by vacuum.
This commit is contained in:
@@ -1,23 +0,0 @@
|
|||||||
package reports
|
|
||||||
|
|
||||||
// SpectralReport represents a datamodel that can be deserialized into a spectral compatible output.
|
|
||||||
type SpectralReport struct {
|
|
||||||
Code string `json:"code" yaml:"code"` // the rule that was run
|
|
||||||
Path []string `json:"path" yaml:"path"` // the path to the item, broken down into a slice
|
|
||||||
Message string `json:"message" yaml:"message"` // the result message
|
|
||||||
Severity int `json:"severity" yaml:"severity"` // the severity reported
|
|
||||||
Range Range `json:"range" yaml:"range"` // the location of the issue in the spec.
|
|
||||||
Source string `json:"source" yaml:"source"` // the source of the report.
|
|
||||||
}
|
|
||||||
|
|
||||||
// Range indicates the start and end of a report item
|
|
||||||
type Range struct {
|
|
||||||
Start RangeItem `json:"start" yaml:"start"`
|
|
||||||
End RangeItem `json:"end" yaml:"end"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// RangeItem indicates the line and character of a range.
|
|
||||||
type RangeItem struct {
|
|
||||||
Line int `json:"line" yaml:"line"`
|
|
||||||
Char int `json:"character" yaml:"character"`
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
package reports
|
|
||||||
|
|
||||||
// ReportStatistics represents statistics for an individual specification report.
|
|
||||||
type ReportStatistics struct {
|
|
||||||
FilesizeKB int `json:"filesizeKb,omitempty" yaml:"filesizeKb,omitempty"`
|
|
||||||
FilesizeBytes int `json:"filesizeBytes,omitempty" yaml:"filesizeBytes,omitempty"`
|
|
||||||
SpecType string `json:"specType,omitempty" yaml:"specType,omitempty"`
|
|
||||||
SpecFormat string `json:"specFormat,omitempty" yaml:"specFormat,omitempty"`
|
|
||||||
Version string `json:"version,omitempty" yaml:"version,omitempty"`
|
|
||||||
References int `json:"references,omitempty" yaml:"references,omitempty"`
|
|
||||||
ExternalDocs int `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"`
|
|
||||||
Schemas int `json:"schemas,omitempty" yaml:"schemas,omitempty"`
|
|
||||||
Parameters int `json:"parameters,omitempty" yaml:"parameters,omitempty"`
|
|
||||||
Links int `json:"links,omitempty" yaml:"links,omitempty"`
|
|
||||||
Paths int `json:"paths,omitempty" yaml:"paths,omitempty"`
|
|
||||||
Operations int `json:"operations,omitempty" yaml:"operations,omitempty"`
|
|
||||||
Tags int `json:"tags,omitempty" yaml:"tags,omitempty"`
|
|
||||||
Examples int `json:"examples,omitempty" yaml:"examples,omitempty"`
|
|
||||||
Enums int `json:"enums,omitempty" yaml:"enums,omitempty"`
|
|
||||||
Security int `json:"security,omitempty" yaml:"security,omitempty"`
|
|
||||||
OverallScore int `json:"overallScore,omitempty" yaml:"overallScore,omitempty"`
|
|
||||||
TotalErrors int `json:"totalErrors,omitempty" yaml:"totalErrors,omitempty"`
|
|
||||||
TotalWarnings int `json:"totalWarnings,omitempty" yaml:"totalWarnings,omitempty"`
|
|
||||||
TotalInfo int `json:"totalInfo,omitempty" yaml:"totalInfo,omitempty"`
|
|
||||||
TotalHints int `json:"totalHints,omitempty" yaml:"totalHints,omitempty"`
|
|
||||||
CategoryStatistics []*CategoryStatistic `json:"categoryStatistics,omitempty" yaml:"categoryStatistics,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// CategoryStatistic represents the number of issues for a particular category
|
|
||||||
type CategoryStatistic struct {
|
|
||||||
CategoryName string `json:"categoryName" yaml:"categoryName"`
|
|
||||||
CategoryId string `json:"categoryId" yaml:"categoryId"`
|
|
||||||
NumIssues int `json:"numIssues" yaml:"numIssues"`
|
|
||||||
Score int `json:"score" yaml:"score"`
|
|
||||||
Warnings int `json:"warnings" yaml:"warnings"`
|
|
||||||
Errors int `json:"errors" yaml:"errors"`
|
|
||||||
Info int `json:"info" yaml:"info"`
|
|
||||||
Hints int `json:"hints" yaml:"hints"`
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
package datamodel
|
|
||||||
|
|
||||||
import (
|
|
||||||
"gopkg.in/yaml.v3"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
// SpecInfo represents information about a supplied specification.
|
|
||||||
type SpecInfo struct {
|
|
||||||
SpecType string `json:"type"`
|
|
||||||
Version string `json:"version"`
|
|
||||||
SpecFormat string `json:"format"`
|
|
||||||
SpecFileType string `json:"fileType"`
|
|
||||||
RootNode *yaml.Node `json:"-"` // reference to the root node of the spec.
|
|
||||||
SpecBytes *[]byte `json:"bytes"` // the original bytes
|
|
||||||
SpecJSONBytes *[]byte `json:"-"` // original bytes converted to JSON
|
|
||||||
SpecJSON *map[string]interface{} `json:"-"` // standard JSON map of original bytes
|
|
||||||
Error error `json:"-"` // something go wrong?
|
|
||||||
APISchema string `json:"-"` // API Schema for supplied spec type (2 or 3)
|
|
||||||
Generated time.Time `json:"-"`
|
|
||||||
jsonParsingChannel chan bool
|
|
||||||
}
|
|
||||||
|
|
||||||
// SearchResult represents the position of a result in a specification.
|
|
||||||
type SearchResult struct {
|
|
||||||
Key string `json:"key"`
|
|
||||||
Line int `json:"line"`
|
|
||||||
Col int `json:"col"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetJSONParsingChannel returns a channel that will close once async JSON parsing is completed.
|
|
||||||
// This is required as rules may start executing before we're even done reading in the spec to JSON.
|
|
||||||
func (si SpecInfo) GetJSONParsingChannel() chan bool {
|
|
||||||
return si.jsonParsingChannel
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
// Copyright 2022 Dave Shanley / Quobix
|
// Copyright 2022 Dave Shanley / Quobix
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
package datamodel
|
package index
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package datamodel
|
package index
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
Reference in New Issue
Block a user