mirror of
https://github.com/aljazceru/kata-containers.git
synced 2026-01-29 11:14:31 +01:00
vendor: move to go mod
Get rid of go dep finally ;) Signed-off-by: Peng Tao <bergwolf@hyper.sh>
This commit is contained in:
5
src/runtime/vendor/github.com/go-openapi/analysis/.gitignore
generated
vendored
Normal file
5
src/runtime/vendor/github.com/go-openapi/analysis/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
secrets.yml
|
||||
coverage.out
|
||||
coverage.txt
|
||||
*.cov
|
||||
.idea
|
||||
19
src/runtime/vendor/github.com/go-openapi/analysis/.golangci.yml
generated
vendored
Normal file
19
src/runtime/vendor/github.com/go-openapi/analysis/.golangci.yml
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
linters-settings:
|
||||
govet:
|
||||
check-shadowing: true
|
||||
golint:
|
||||
min-confidence: 0
|
||||
gocyclo:
|
||||
min-complexity: 30
|
||||
maligned:
|
||||
suggest-new: true
|
||||
dupl:
|
||||
threshold: 100
|
||||
goconst:
|
||||
min-len: 2
|
||||
min-occurrences: 4
|
||||
|
||||
linters:
|
||||
enable-all: true
|
||||
disable:
|
||||
- maligned
|
||||
24
src/runtime/vendor/github.com/go-openapi/analysis/.travis.yml
generated
vendored
Normal file
24
src/runtime/vendor/github.com/go-openapi/analysis/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
go:
|
||||
- '1.9'
|
||||
- 1.10.x
|
||||
- 1.11.x
|
||||
install:
|
||||
- go get -u github.com/axw/gocov/gocov
|
||||
- go get -u gopkg.in/matm/v1/gocov-html
|
||||
- go get -u github.com/cee-dub/go-junit-report
|
||||
- go get -u github.com/docker/go-units
|
||||
- go get -u github.com/stretchr/testify/assert
|
||||
- go get -u gopkg.in/yaml.v2
|
||||
- go get -u github.com/go-openapi/swag
|
||||
- go get -u github.com/go-openapi/jsonpointer
|
||||
- go get -u github.com/go-openapi/spec
|
||||
- go get -u github.com/go-openapi/strfmt
|
||||
- go get -u github.com/go-openapi/loads/fmts
|
||||
language: go
|
||||
notifications:
|
||||
slack:
|
||||
secure: Sf7kZf7ZGbnwWUMpffHwMu5A0cHkLK2MYY32LNTPj4+/3qC3Ghl7+9v4TSLOqOlCwdRNjOGblAq7s+GDJed6/xgRQl1JtCi1klzZNrYX4q01pgTPvvGcwbBkIYgeMaPeIRcK9OZnud7sRXdttozgTOpytps2U6Js32ip7uj5mHSg2ub0FwoSJwlS6dbezZ8+eDhoha0F/guY99BEwx8Bd+zROrT2TFGsSGOFGN6wFc7moCqTHO/YkWib13a2QNXqOxCCVBy/lt76Wp+JkeFppjHlzs/2lP3EAk13RIUAaesdEUHvIHrzCyNJEd3/+KO2DzsWOYfpktd+KBCvgaYOsoo7ubdT3IROeAegZdCgo/6xgCEsmFc9ZcqCfN5yNx2A+BZ2Vwmpws+bQ1E1+B5HDzzaiLcYfG4X2O210QVGVDLWsv1jqD+uPYeHY2WRfh5ZsIUFvaqgUEnwHwrK44/8REAhQavt1QAj5uJpsRd7CkRVPWRNK+yIky+wgbVUFEchRNmS55E7QWf+W4+4QZkQi7vUTMc9nbTUu2Es9NfvfudOpM2wZbn98fjpb/qq/nRv6Bk+ca+7XD5/IgNLMbWp2ouDdzbiHLCOfDUiHiDJhLfFZx9Bwo7ZwfzeOlbrQX66bx7xRKYmOe4DLrXhNcpbsMa8qbfxlZRCmYbubB/Y8h4=
|
||||
script:
|
||||
- hack/coverage
|
||||
74
src/runtime/vendor/github.com/go-openapi/analysis/CODE_OF_CONDUCT.md
generated
vendored
Normal file
74
src/runtime/vendor/github.com/go-openapi/analysis/CODE_OF_CONDUCT.md
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, gender identity and expression, level of experience,
|
||||
nationality, personal appearance, race, religion, or sexual identity and
|
||||
orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project team at ivan+abuse@flanders.co.nz. All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at [http://contributor-covenant.org/version/1/4][version]
|
||||
|
||||
[homepage]: http://contributor-covenant.org
|
||||
[version]: http://contributor-covenant.org/version/1/4/
|
||||
9
src/runtime/vendor/github.com/go-openapi/analysis/README.md
generated
vendored
Normal file
9
src/runtime/vendor/github.com/go-openapi/analysis/README.md
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
# OpenAPI initiative analysis [](https://travis-ci.org/go-openapi/analysis) [](https://codecov.io/gh/go-openapi/analysis) [](https://slackin.goswagger.io)
|
||||
|
||||
[](https://raw.githubusercontent.com/go-openapi/analysis/master/LICENSE)
|
||||
[](http://godoc.org/github.com/go-openapi/analysis)
|
||||
[](https://golangci.com)
|
||||
[](https://goreportcard.com/report/github.com/go-openapi/analysis)
|
||||
|
||||
|
||||
A foundational library to analyze an OAI specification document for easier reasoning about the content.
|
||||
104
src/runtime/vendor/github.com/go-openapi/analysis/analyzer.go
generated
vendored
104
src/runtime/vendor/github.com/go-openapi/analysis/analyzer.go
generated
vendored
@@ -104,38 +104,6 @@ func (p *patternAnalysis) addSchemaPattern(key, pattern string) {
|
||||
p.addPattern(key, pattern)
|
||||
}
|
||||
|
||||
type enumAnalysis struct {
|
||||
parameters map[string][]interface{}
|
||||
headers map[string][]interface{}
|
||||
items map[string][]interface{}
|
||||
schemas map[string][]interface{}
|
||||
allEnums map[string][]interface{}
|
||||
}
|
||||
|
||||
func (p *enumAnalysis) addEnum(key string, enum []interface{}) {
|
||||
p.allEnums["#"+key] = enum
|
||||
}
|
||||
|
||||
func (p *enumAnalysis) addParameterEnum(key string, enum []interface{}) {
|
||||
p.parameters["#"+key] = enum
|
||||
p.addEnum(key, enum)
|
||||
}
|
||||
|
||||
func (p *enumAnalysis) addHeaderEnum(key string, enum []interface{}) {
|
||||
p.headers["#"+key] = enum
|
||||
p.addEnum(key, enum)
|
||||
}
|
||||
|
||||
func (p *enumAnalysis) addItemsEnum(key string, enum []interface{}) {
|
||||
p.items["#"+key] = enum
|
||||
p.addEnum(key, enum)
|
||||
}
|
||||
|
||||
func (p *enumAnalysis) addSchemaEnum(key string, enum []interface{}) {
|
||||
p.schemas["#"+key] = enum
|
||||
p.addEnum(key, enum)
|
||||
}
|
||||
|
||||
// New takes a swagger spec object and returns an analyzed spec document.
|
||||
// The analyzed document contains a number of indices that make it easier to
|
||||
// reason about semantics of a swagger specification for use in code generation
|
||||
@@ -166,13 +134,6 @@ func New(doc *spec.Swagger) *Spec {
|
||||
schemas: make(map[string]string, 150),
|
||||
allPatterns: make(map[string]string, 150),
|
||||
},
|
||||
enums: enumAnalysis{
|
||||
parameters: make(map[string][]interface{}, 150),
|
||||
headers: make(map[string][]interface{}, 150),
|
||||
items: make(map[string][]interface{}, 150),
|
||||
schemas: make(map[string][]interface{}, 150),
|
||||
allEnums: make(map[string][]interface{}, 150),
|
||||
},
|
||||
}
|
||||
a.initialize()
|
||||
return a
|
||||
@@ -188,7 +149,6 @@ type Spec struct {
|
||||
operations map[string]map[string]*spec.Operation
|
||||
references referenceAnalysis
|
||||
patterns patternAnalysis
|
||||
enums enumAnalysis
|
||||
allSchemas map[string]SchemaRef
|
||||
allOfs map[string]SchemaRef
|
||||
}
|
||||
@@ -213,11 +173,6 @@ func (s *Spec) reset() {
|
||||
s.patterns.items = make(map[string]string, 150)
|
||||
s.patterns.schemas = make(map[string]string, 150)
|
||||
s.patterns.allPatterns = make(map[string]string, 150)
|
||||
s.enums.parameters = make(map[string][]interface{}, 150)
|
||||
s.enums.headers = make(map[string][]interface{}, 150)
|
||||
s.enums.items = make(map[string][]interface{}, 150)
|
||||
s.enums.schemas = make(map[string][]interface{}, 150)
|
||||
s.enums.allEnums = make(map[string][]interface{}, 150)
|
||||
}
|
||||
|
||||
func (s *Spec) reload() {
|
||||
@@ -252,9 +207,6 @@ func (s *Spec) initialize() {
|
||||
if parameter.Pattern != "" {
|
||||
s.patterns.addParameterPattern(refPref, parameter.Pattern)
|
||||
}
|
||||
if len(parameter.Enum) > 0 {
|
||||
s.enums.addParameterEnum(refPref, parameter.Enum)
|
||||
}
|
||||
}
|
||||
|
||||
for name, response := range s.spec.Responses {
|
||||
@@ -267,9 +219,6 @@ func (s *Spec) initialize() {
|
||||
if v.Pattern != "" {
|
||||
s.patterns.addHeaderPattern(hRefPref, v.Pattern)
|
||||
}
|
||||
if len(v.Enum) > 0 {
|
||||
s.enums.addHeaderEnum(hRefPref, v.Enum)
|
||||
}
|
||||
}
|
||||
if response.Schema != nil {
|
||||
s.analyzeSchema("schema", *response.Schema, refPref)
|
||||
@@ -307,9 +256,6 @@ func (s *Spec) analyzeOperations(path string, pi *spec.PathItem) {
|
||||
if param.Pattern != "" {
|
||||
s.patterns.addParameterPattern(refPref, param.Pattern)
|
||||
}
|
||||
if len(param.Enum) > 0 {
|
||||
s.enums.addParameterEnum(refPref, param.Enum)
|
||||
}
|
||||
if param.Items != nil {
|
||||
s.analyzeItems("items", param.Items, refPref, "parameter")
|
||||
}
|
||||
@@ -331,9 +277,6 @@ func (s *Spec) analyzeItems(name string, items *spec.Items, prefix, location str
|
||||
if items.Pattern != "" {
|
||||
s.patterns.addItemsPattern(refPref, items.Pattern)
|
||||
}
|
||||
if len(items.Enum) > 0 {
|
||||
s.enums.addItemsEnum(refPref, items.Enum)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Spec) analyzeOperation(method, path string, op *spec.Operation) {
|
||||
@@ -365,9 +308,6 @@ func (s *Spec) analyzeOperation(method, path string, op *spec.Operation) {
|
||||
if param.Pattern != "" {
|
||||
s.patterns.addParameterPattern(refPref, param.Pattern)
|
||||
}
|
||||
if len(param.Enum) > 0 {
|
||||
s.enums.addParameterEnum(refPref, param.Enum)
|
||||
}
|
||||
s.analyzeItems("items", param.Items, refPref, "parameter")
|
||||
if param.In == "body" && param.Schema != nil {
|
||||
s.analyzeSchema("schema", *param.Schema, refPref)
|
||||
@@ -401,9 +341,6 @@ func (s *Spec) analyzeOperation(method, path string, op *spec.Operation) {
|
||||
if v.Pattern != "" {
|
||||
s.patterns.addHeaderPattern(hRefPref, v.Pattern)
|
||||
}
|
||||
if len(v.Enum) > 0 {
|
||||
s.enums.addHeaderEnum(hRefPref, v.Enum)
|
||||
}
|
||||
}
|
||||
if res.Schema != nil {
|
||||
s.analyzeSchema("schema", *res.Schema, refPref)
|
||||
@@ -429,9 +366,6 @@ func (s *Spec) analyzeSchema(name string, schema spec.Schema, prefix string) {
|
||||
if schema.Pattern != "" {
|
||||
s.patterns.addSchemaPattern(refURI, schema.Pattern)
|
||||
}
|
||||
if len(schema.Enum) > 0 {
|
||||
s.enums.addSchemaEnum(refURI, schema.Enum)
|
||||
}
|
||||
|
||||
for k, v := range schema.Definitions {
|
||||
s.analyzeSchema(k, v, slashpath.Join(refURI, "definitions"))
|
||||
@@ -927,14 +861,6 @@ func cloneStringMap(source map[string]string) map[string]string {
|
||||
return res
|
||||
}
|
||||
|
||||
func cloneEnumMap(source map[string][]interface{}) map[string][]interface{} {
|
||||
res := make(map[string][]interface{}, len(source))
|
||||
for k, v := range source {
|
||||
res[k] = v
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
// ParameterPatterns returns all the patterns found in parameters
|
||||
// the map is cloned to avoid accidental changes
|
||||
func (s *Spec) ParameterPatterns() map[string]string {
|
||||
@@ -964,33 +890,3 @@ func (s *Spec) SchemaPatterns() map[string]string {
|
||||
func (s *Spec) AllPatterns() map[string]string {
|
||||
return cloneStringMap(s.patterns.allPatterns)
|
||||
}
|
||||
|
||||
// ParameterEnums returns all the enums found in parameters
|
||||
// the map is cloned to avoid accidental changes
|
||||
func (s *Spec) ParameterEnums() map[string][]interface{} {
|
||||
return cloneEnumMap(s.enums.parameters)
|
||||
}
|
||||
|
||||
// HeaderEnums returns all the enums found in response headers
|
||||
// the map is cloned to avoid accidental changes
|
||||
func (s *Spec) HeaderEnums() map[string][]interface{} {
|
||||
return cloneEnumMap(s.enums.headers)
|
||||
}
|
||||
|
||||
// ItemsEnums returns all the enums found in simple array items
|
||||
// the map is cloned to avoid accidental changes
|
||||
func (s *Spec) ItemsEnums() map[string][]interface{} {
|
||||
return cloneEnumMap(s.enums.items)
|
||||
}
|
||||
|
||||
// SchemaEnums returns all the enums found in schemas
|
||||
// the map is cloned to avoid accidental changes
|
||||
func (s *Spec) SchemaEnums() map[string][]interface{} {
|
||||
return cloneEnumMap(s.enums.schemas)
|
||||
}
|
||||
|
||||
// AllEnums returns all the enums found in the spec
|
||||
// the map is cloned to avoid accidental changes
|
||||
func (s *Spec) AllEnums() map[string][]interface{} {
|
||||
return cloneEnumMap(s.enums.allEnums)
|
||||
}
|
||||
|
||||
127
src/runtime/vendor/github.com/go-openapi/analysis/flatten.go
generated
vendored
127
src/runtime/vendor/github.com/go-openapi/analysis/flatten.go
generated
vendored
@@ -75,14 +75,12 @@ type newRef struct {
|
||||
type context struct {
|
||||
newRefs map[string]*newRef
|
||||
warnings []string
|
||||
resolved map[string]string
|
||||
}
|
||||
|
||||
func newContext() *context {
|
||||
return &context{
|
||||
newRefs: make(map[string]*newRef, 150),
|
||||
warnings: make([]string, 0),
|
||||
resolved: make(map[string]string, 50),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,9 +141,8 @@ func Flatten(opts FlattenOpts) error {
|
||||
|
||||
opts.flattenContext = newContext()
|
||||
|
||||
// recursively expand responses, parameters, path items and items in simple schemas.
|
||||
// This simplifies the spec and leaves $ref only into schema objects.
|
||||
//
|
||||
// recursively expand responses, parameters, path items and items in simple schemas
|
||||
// TODO: we should not expand discriminated types
|
||||
if err := swspec.ExpandSpec(opts.Swagger(), opts.ExpandOpts(!opts.Expand)); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -166,13 +163,10 @@ func Flatten(opts FlattenOpts) error {
|
||||
opts.Spec.reload() // re-analyze
|
||||
|
||||
// at this point there are no other references left but schemas
|
||||
for imported := false; !imported; {
|
||||
var err error
|
||||
if imported, err = importExternalReferences(&opts); err != nil {
|
||||
return err
|
||||
}
|
||||
opts.Spec.reload() // re-analyze
|
||||
if err := importExternalReferences(&opts); err != nil {
|
||||
return err
|
||||
}
|
||||
opts.Spec.reload() // re-analyze
|
||||
|
||||
if !opts.Minimal && !opts.Expand {
|
||||
// full flattening: rewrite inline schemas (schemas that aren't simple types or arrays or maps)
|
||||
@@ -182,6 +176,7 @@ func Flatten(opts FlattenOpts) error {
|
||||
|
||||
opts.Spec.reload() // re-analyze
|
||||
}
|
||||
|
||||
// rewrite JSON pointers other than $ref to named definitions
|
||||
// and attempts to resolve conflicting names
|
||||
if err := stripPointersAndOAIGen(&opts); err != nil {
|
||||
@@ -517,10 +512,7 @@ const (
|
||||
definitionsPath = "#/definitions"
|
||||
)
|
||||
|
||||
var (
|
||||
ignoredKeys map[string]struct{}
|
||||
validMethods map[string]struct{}
|
||||
)
|
||||
var ignoredKeys map[string]struct{}
|
||||
|
||||
func init() {
|
||||
ignoredKeys = map[string]struct{}{
|
||||
@@ -530,16 +522,6 @@ func init() {
|
||||
"anyOf": {},
|
||||
"oneOf": {},
|
||||
}
|
||||
|
||||
validMethods = map[string]struct{}{
|
||||
"GET": {},
|
||||
"HEAD": {},
|
||||
"OPTIONS": {},
|
||||
"PATCH": {},
|
||||
"POST": {},
|
||||
"PUT": {},
|
||||
"DELETE": {},
|
||||
}
|
||||
}
|
||||
|
||||
type splitKey []string
|
||||
@@ -637,12 +619,26 @@ func (s splitKey) ResponseName() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
var validMethods map[string]struct{}
|
||||
|
||||
func init() {
|
||||
validMethods = map[string]struct{}{
|
||||
"GET": {},
|
||||
"HEAD": {},
|
||||
"OPTIONS": {},
|
||||
"PATCH": {},
|
||||
"POST": {},
|
||||
"PUT": {},
|
||||
"DELETE": {},
|
||||
}
|
||||
}
|
||||
|
||||
func (s splitKey) PathItemRef() swspec.Ref {
|
||||
if len(s) < 3 {
|
||||
return swspec.Ref{}
|
||||
}
|
||||
pth, method := s[1], s[2]
|
||||
if _, isValidMethod := validMethods[strings.ToUpper(method)]; !isValidMethod && !strings.HasPrefix(method, "x-") {
|
||||
if _, validMethod := validMethods[strings.ToUpper(method)]; !validMethod && !strings.HasPrefix(method, "x-") {
|
||||
return swspec.Ref{}
|
||||
}
|
||||
return swspec.MustCreateRef("#" + slashpath.Join("/", paths, jsonpointer.Escape(pth), strings.ToUpper(method)))
|
||||
@@ -781,12 +777,9 @@ func cloneSchema(schema *swspec.Schema) (*swspec.Schema, error) {
|
||||
return &sch, nil
|
||||
}
|
||||
|
||||
func importExternalReferences(opts *FlattenOpts) (bool, error) {
|
||||
func importExternalReferences(opts *FlattenOpts) error {
|
||||
groupedRefs := reverseIndexForSchemaRefs(opts)
|
||||
sortedRefStr := make([]string, 0, len(groupedRefs))
|
||||
if opts.flattenContext == nil {
|
||||
opts.flattenContext = newContext()
|
||||
}
|
||||
|
||||
// sort $ref resolution to ensure deterministic name conflict resolution
|
||||
for refStr := range groupedRefs {
|
||||
@@ -794,53 +787,35 @@ func importExternalReferences(opts *FlattenOpts) (bool, error) {
|
||||
}
|
||||
sort.Strings(sortedRefStr)
|
||||
|
||||
complete := true
|
||||
for _, refStr := range sortedRefStr {
|
||||
entry := groupedRefs[refStr]
|
||||
if !entry.Ref.HasFragmentOnly {
|
||||
complete = false
|
||||
var isOAIGen bool
|
||||
debugLog("importing external schema for [%s] from %s", strings.Join(entry.Keys, ", "), refStr)
|
||||
// resolve to actual schema
|
||||
sch := new(swspec.Schema)
|
||||
sch.Ref = entry.Ref
|
||||
if err := swspec.ExpandSchemaWithBasePath(sch, nil, opts.ExpandOpts(false)); err != nil {
|
||||
return err
|
||||
}
|
||||
if sch == nil {
|
||||
return fmt.Errorf("no schema found at %s for [%s]", refStr, strings.Join(entry.Keys, ", "))
|
||||
}
|
||||
debugLog("importing external schema for [%s] from %s", strings.Join(entry.Keys, ", "), refStr)
|
||||
|
||||
newName := opts.flattenContext.resolved[refStr]
|
||||
if newName != "" {
|
||||
// rewrite ref with already resolved external ref (useful for cyclicali refs)
|
||||
debugLog("resolving known ref [%s] to %s", refStr, newName)
|
||||
// rewrite the external refs to local ones
|
||||
for _, key := range entry.Keys {
|
||||
if err := updateRef(opts.Swagger(), key,
|
||||
swspec.MustCreateRef(slashpath.Join(definitionsPath, newName))); err != nil {
|
||||
return false, err
|
||||
}
|
||||
// generate a unique name - isOAIGen means that a naming conflict was resolved by changing the name
|
||||
newName, isOAIGen := uniqifyName(opts.Swagger().Definitions, nameFromRef(entry.Ref))
|
||||
debugLog("new name for [%s]: %s - with name conflict:%t",
|
||||
strings.Join(entry.Keys, ", "), newName, isOAIGen)
|
||||
|
||||
// rewrite the external refs to local ones
|
||||
for _, key := range entry.Keys {
|
||||
if err := updateRef(opts.Swagger(), key,
|
||||
swspec.MustCreateRef(slashpath.Join(definitionsPath, newName))); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
debugLog("importing external schema for [%s] from %s", strings.Join(entry.Keys, ", "), refStr)
|
||||
|
||||
// resolve to actual schema
|
||||
sch := new(swspec.Schema)
|
||||
sch.Ref = entry.Ref
|
||||
if err := swspec.ExpandSchemaWithBasePath(sch, nil, opts.ExpandOpts(false)); err != nil {
|
||||
return false, err
|
||||
}
|
||||
if sch == nil {
|
||||
return false, fmt.Errorf("no schema found at %s for [%s]", refStr, strings.Join(entry.Keys, ", "))
|
||||
}
|
||||
debugLog("importing external schema for [%s] from %s", strings.Join(entry.Keys, ", "), refStr)
|
||||
|
||||
// generate a unique name - isOAIGen means that a naming conflict was resolved by changing the name
|
||||
newName, isOAIGen = uniqifyName(opts.Swagger().Definitions, nameFromRef(entry.Ref))
|
||||
debugLog("new name for [%s]: %s - with name conflict:%t",
|
||||
strings.Join(entry.Keys, ", "), newName, isOAIGen)
|
||||
|
||||
opts.flattenContext.resolved[refStr] = newName
|
||||
|
||||
// rewrite the external refs to local ones
|
||||
for _, key := range entry.Keys {
|
||||
if err := updateRef(opts.Swagger(), key,
|
||||
swspec.MustCreateRef(slashpath.Join(definitionsPath, newName))); err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
// keep track of created refs
|
||||
// keep track of created refs
|
||||
if opts.flattenContext != nil {
|
||||
resolved := false
|
||||
if _, ok := opts.flattenContext.newRefs[key]; ok {
|
||||
resolved = opts.flattenContext.newRefs[key].resolved
|
||||
@@ -854,13 +829,13 @@ func importExternalReferences(opts *FlattenOpts) (bool, error) {
|
||||
schema: sch,
|
||||
}
|
||||
}
|
||||
|
||||
// add the resolved schema to the definitions
|
||||
saveSchema(opts.Swagger(), newName, sch)
|
||||
}
|
||||
|
||||
// add the resolved schema to the definitions
|
||||
saveSchema(opts.Swagger(), newName, sch)
|
||||
}
|
||||
}
|
||||
return complete, nil
|
||||
return nil
|
||||
}
|
||||
|
||||
type refRevIdx struct {
|
||||
@@ -1284,6 +1259,7 @@ func croak(opts *FlattenOpts) {
|
||||
func namePointers(opts *FlattenOpts) error {
|
||||
debugLog("name pointers")
|
||||
refsToReplace := make(map[string]SchemaRef, len(opts.Spec.references.schemas))
|
||||
//for k, ref := range opts.Spec.references.schemas {
|
||||
for k, ref := range opts.Spec.references.allRefs {
|
||||
if slashpath.Dir(ref.String()) == definitionsPath {
|
||||
// this a ref to a top-level definition: ok
|
||||
@@ -1401,7 +1377,6 @@ func namePointers(opts *FlattenOpts) error {
|
||||
// NOTE: all external $ref's are assumed to be already expanded at this stage.
|
||||
func deepestRef(opts *FlattenOpts, ref swspec.Ref) (swspec.Ref, *swspec.Schema, error) {
|
||||
if !ref.HasFragmentOnly {
|
||||
// we found an external $ref, which is odd
|
||||
// does nothing on external $refs
|
||||
return ref, nil, nil
|
||||
}
|
||||
|
||||
10
src/runtime/vendor/github.com/go-openapi/analysis/go.mod
generated
vendored
Normal file
10
src/runtime/vendor/github.com/go-openapi/analysis/go.mod
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
module github.com/go-openapi/analysis
|
||||
|
||||
require (
|
||||
github.com/go-openapi/jsonpointer v0.17.0
|
||||
github.com/go-openapi/loads v0.17.0
|
||||
github.com/go-openapi/spec v0.17.0
|
||||
github.com/go-openapi/strfmt v0.17.0
|
||||
github.com/go-openapi/swag v0.17.0
|
||||
github.com/stretchr/testify v1.2.2
|
||||
)
|
||||
37
src/runtime/vendor/github.com/go-openapi/analysis/go.sum
generated
vendored
Normal file
37
src/runtime/vendor/github.com/go-openapi/analysis/go.sum
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
github.com/PuerkitoBio/purell v1.1.0 h1:rmGxhojJlM0tuKtfdvliR84CFHljx9ag64t2xmVkjK4=
|
||||
github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M=
|
||||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
|
||||
github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf h1:eg0MeVzsP1G42dRafH3vf+al2vQIJU0YHX+1Tw87oco=
|
||||
github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb h1:D4uzjWwKYQ5XnAvUbuvHW93esHg7F8N/OYeBBcJoTr0=
|
||||
github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q=
|
||||
github.com/go-openapi/analysis v0.0.0-20180825180245-b006789cd277/go.mod h1:k70tL6pCuVxPJOHXQ+wIac1FUrvNkHolPie/cLEU6hI=
|
||||
github.com/go-openapi/errors v0.17.0 h1:47T+LqPrQUxFXQnB22aLBfsTRFSqWp5y4OiFgQm+/Lw=
|
||||
github.com/go-openapi/errors v0.17.0/go.mod h1:La0D2x9HoXenv7MDEiAv6vWoe84CXFo0PQRk/jdQlww=
|
||||
github.com/go-openapi/jsonpointer v0.17.0 h1:Bpl2DtZ6k7wKqfFs7e+4P08+M9I3FQgn09a1UsRUQbk=
|
||||
github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0=
|
||||
github.com/go-openapi/jsonreference v0.17.0 h1:d/o7/fsLWWQZACbihvZxcyLQ59jfUVs7WOJv/ak7T7A=
|
||||
github.com/go-openapi/jsonreference v0.17.0/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg=
|
||||
github.com/go-openapi/loads v0.17.0 h1:H22nMs3GDQk4SwAaFQ+jLNw+0xoFeCueawhZlv8MBYs=
|
||||
github.com/go-openapi/loads v0.17.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU=
|
||||
github.com/go-openapi/spec v0.17.0 h1:MM5YaXBdBOEcjGHW5WayrAY5Ze2ydNyy71JHeTi7xUc=
|
||||
github.com/go-openapi/spec v0.17.0/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc=
|
||||
github.com/go-openapi/strfmt v0.17.0 h1:79+bCyGHowS3rkr6z8RcG5jVzdKpeKXlDuW6yqE50TM=
|
||||
github.com/go-openapi/strfmt v0.17.0/go.mod h1:/bCWipNKhC9QMhD8HRe2EGbU8G0D4Yvh0G6X4k1Xwvg=
|
||||
github.com/go-openapi/swag v0.17.0 h1:7wu+dZ5k83kvUWeAb+WUkFiUhDzwGqzTR/NhWzeo1JU=
|
||||
github.com/go-openapi/swag v0.17.0/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I=
|
||||
github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329 h1:2gxZ0XQIU/5z3Z3bUBu+FXuk2pFbkN6tcwi/pjyaDic=
|
||||
github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
golang.org/x/net v0.0.0-20181005035420-146acd28ed58 h1:otZG8yDCO4LVps5+9bxOeNiCvgmOyt96J3roHTYs7oE=
|
||||
golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
6
src/runtime/vendor/github.com/go-openapi/analysis/schema.go
generated
vendored
6
src/runtime/vendor/github.com/go-openapi/analysis/schema.go
generated
vendored
@@ -1,8 +1,6 @@
|
||||
package analysis
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/go-openapi/spec"
|
||||
"github.com/go-openapi/strfmt"
|
||||
)
|
||||
@@ -18,10 +16,6 @@ type SchemaOpts struct {
|
||||
// Schema analysis, will classify the schema according to known
|
||||
// patterns.
|
||||
func Schema(opts SchemaOpts) (*AnalyzedSchema, error) {
|
||||
if opts.Schema == nil {
|
||||
return nil, fmt.Errorf("no schema to analyze")
|
||||
}
|
||||
|
||||
a := &AnalyzedSchema{
|
||||
schema: opts.Schema,
|
||||
root: opts.Root,
|
||||
|
||||
Reference in New Issue
Block a user