mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-10 12:37:48 +00:00
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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user