Files
libopenapi/datamodel/high/v2/security_scheme.go
Dave Shanley 3d5ecf0efb Refactored version directory names
3.0 and 2.0 do not work, there are multiple versions and anything with a period in it sucks from my point of view, v2 and v3 feel much better from a DX perspective.
2022-09-16 08:33:39 -04:00

58 lines
1.5 KiB
Go

// Copyright 2022 Princess B33f Heavy Industries / Dave Shanley
// SPDX-License-Identifier: MIT
package v2
import (
"github.com/pb33f/libopenapi/datamodel/high"
low "github.com/pb33f/libopenapi/datamodel/low/v2"
)
type SecurityScheme struct {
Type string
Description string
Name string
In string
Flow string
AuthorizationUrl string
TokenUrl string
Scopes *Scopes
Extensions map[string]any
low *low.SecurityScheme
}
func NewSecurityScheme(securityScheme *low.SecurityScheme) *SecurityScheme {
s := new(SecurityScheme)
s.low = securityScheme
s.Extensions = high.ExtractExtensions(securityScheme.Extensions)
if !securityScheme.Type.IsEmpty() {
s.Type = securityScheme.Type.Value
}
if !securityScheme.Description.IsEmpty() {
s.Description = securityScheme.Description.Value
}
if !securityScheme.Name.IsEmpty() {
s.Name = securityScheme.Name.Value
}
if !securityScheme.In.IsEmpty() {
s.In = securityScheme.In.Value
}
if !securityScheme.Flow.IsEmpty() {
s.Flow = securityScheme.Flow.Value
}
if !securityScheme.AuthorizationUrl.IsEmpty() {
s.AuthorizationUrl = securityScheme.AuthorizationUrl.Value
}
if !securityScheme.TokenUrl.IsEmpty() {
s.TokenUrl = securityScheme.TokenUrl.Value
}
if !securityScheme.Scopes.IsEmpty() {
s.Scopes = NewScopes(securityScheme.Scopes.Value)
}
return s
}
func (s *SecurityScheme) GoLow() *low.SecurityScheme {
return s.low
}