Refactored SecurityRequirement **breaking change**

The v3 model is wrong and out of sync with the spec. It's been corrected, so the v2 and v2 model for SecurityRequirement have been collapsed down into a base model., they are the same data structures. This has allowed me to delete the complexity of sharing two different models for the same structure, by unifying the model correctly. I am not sure why I decided to change the v3 model, oh well, its been corrected. Long live swagger!
This commit is contained in:
Dave Shanley
2022-11-02 10:02:53 -04:00
parent 4b30fe3622
commit d27e66ff3d
21 changed files with 308 additions and 469 deletions

View File

@@ -59,7 +59,7 @@ type Document struct {
// to authorize a request. Individual operations can override this definition. To make security optional,
// an empty security requirement ({}) can be included in the array.
// - https://spec.openapis.org/oas/v3.1.0#security-requirement-object
Security low.NodeReference[*SecurityRequirement]
Security low.NodeReference[[]low.ValueReference[*base.SecurityRequirement]]
// Tags is a slice of base.Tag instances defined by the specification
// A list of tags used by the document with additional metadata. The order of the tags can be used to reflect on
@@ -84,6 +84,18 @@ type Document struct {
Index *index.SpecIndex
}
// FindSecurityRequirement will attempt to locate a security requirement string from a supplied name.
func (d *Document) FindSecurityRequirement(name string) []low.ValueReference[string] {
for k := range d.Security.Value {
for i := range d.Security.Value[k].Value.Requirements.Value {
if i.Value == name {
return d.Security.Value[k].Value.Requirements.Value[i].Value
}
}
}
return nil
}
// TODO: this is early prototype mutation/modification code, keeping it around for later.
//func (d *Document) AddTag() *base.Tag {
// t := base.NewTag()