mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-05-25 19:10:55 +00:00
* add line break test to petstore-security-test.yaml * add objc/swift security testing * add go,scala,qt5cpp for security test * add security test for typescript * fix go security issue, fix consumes,produces line break
82 lines
2.9 KiB
Go
82 lines
2.9 KiB
Go
/*
|
|
* Swagger Petstore *_/ ' \" =end \\r\\n \\n \\r
|
|
*
|
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end
|
|
*
|
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end \\r\\n \\n \\r
|
|
* Contact: apiteam@swagger.io *_/ ' \" =end \\r\\n \\n \\r
|
|
* Generated by: https://github.com/swagger-api/swagger-codegen.git
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
package swagger
|
|
|
|
import (
|
|
"encoding/base64"
|
|
)
|
|
|
|
type Configuration struct {
|
|
UserName string `json:"userName,omitempty"`
|
|
Password string `json:"password,omitempty"`
|
|
APIKeyPrefix map[string]string `json:"APIKeyPrefix,omitempty"`
|
|
APIKey map[string]string `json:"APIKey,omitempty"`
|
|
debug bool `json:"debug,omitempty"`
|
|
DebugFile string `json:"debugFile,omitempty"`
|
|
OAuthToken string `json:"oAuthToken,omitempty"`
|
|
Timeout int `json:"timeout,omitempty"`
|
|
BasePath string `json:"basePath,omitempty"`
|
|
Host string `json:"host,omitempty"`
|
|
Scheme string `json:"scheme,omitempty"`
|
|
AccessToken string `json:"accessToken,omitempty"`
|
|
DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
|
|
UserAgent string `json:"userAgent,omitempty"`
|
|
APIClient APIClient `json:"APIClient,omitempty"`
|
|
}
|
|
|
|
func NewConfiguration() *Configuration {
|
|
return &Configuration{
|
|
BasePath: "https://petstore.swagger.io *_/ ' \" =end \\r\\n \\n \\r/v2 *_/ ' \" =end \\r\\n \\n \\r",
|
|
UserName: "",
|
|
debug: false,
|
|
DefaultHeader: make(map[string]string),
|
|
APIKey: make(map[string]string),
|
|
APIKeyPrefix: make(map[string]string),
|
|
UserAgent: "Swagger-Codegen/1.0.0/go",
|
|
}
|
|
}
|
|
|
|
func (c *Configuration) GetBasicAuthEncodedString() string {
|
|
return base64.StdEncoding.EncodeToString([]byte(c.UserName + ":" + c.Password))
|
|
}
|
|
|
|
func (c *Configuration) AddDefaultHeader(key string, value string) {
|
|
c.DefaultHeader[key] = value
|
|
}
|
|
|
|
func (c *Configuration) GetAPIKeyWithPrefix(APIKeyIdentifier string) string {
|
|
if c.APIKeyPrefix[APIKeyIdentifier] != "" {
|
|
return c.APIKeyPrefix[APIKeyIdentifier] + " " + c.APIKey[APIKeyIdentifier]
|
|
}
|
|
|
|
return c.APIKey[APIKeyIdentifier]
|
|
}
|
|
|
|
func (c *Configuration) SetDebug(enable bool) {
|
|
c.debug = enable
|
|
}
|
|
|
|
func (c *Configuration) GetDebug() bool {
|
|
return c.debug
|
|
}
|