diff --git a/datamodel/reports/spectral.go b/datamodel/reports/spectral.go deleted file mode 100644 index b6fe38d..0000000 --- a/datamodel/reports/spectral.go +++ /dev/null @@ -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"` -} diff --git a/datamodel/reports/statistics.go b/datamodel/reports/statistics.go deleted file mode 100644 index d22261e..0000000 --- a/datamodel/reports/statistics.go +++ /dev/null @@ -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"` -} diff --git a/datamodel/spec.go b/datamodel/spec.go deleted file mode 100644 index d06e433..0000000 --- a/datamodel/spec.go +++ /dev/null @@ -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 -} diff --git a/datamodel/spec_index.go b/index/spec_index.go similarity index 99% rename from datamodel/spec_index.go rename to index/spec_index.go index 5904423..af5a214 100644 --- a/datamodel/spec_index.go +++ b/index/spec_index.go @@ -1,7 +1,7 @@ // Copyright 2022 Dave Shanley / Quobix // SPDX-License-Identifier: MIT -package datamodel +package index import ( "errors" diff --git a/datamodel/spec_index_test.go b/index/spec_index_test.go similarity index 99% rename from datamodel/spec_index_test.go rename to index/spec_index_test.go index 8d84818..0d11a11 100644 --- a/datamodel/spec_index_test.go +++ b/index/spec_index_test.go @@ -1,4 +1,4 @@ -package datamodel +package index import ( "github.com/stretchr/testify/assert"