$98 GRAYBYTE WORDPRESS FILE MANAGER $46

SERVER : in-mum-web1330.main-hosting.eu #1 SMP Mon Feb 10 22:45:17 UTC 2025
SERVER IP : 91.108.106.184 | ADMIN IP 216.73.216.215
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/opt/go/pkg/mod/github.com/go-openapi/spec@v0.20.8/

HOME
Current File : /opt/go/pkg/mod/github.com/go-openapi/spec@v0.20.8//responses.go
// Copyright 2015 go-swagger maintainers
//
// 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 spec

import (
	"encoding/json"
	"fmt"
	"reflect"
	"strconv"

	"github.com/go-openapi/swag"
)

// Responses is a container for the expected responses of an operation.
// The container maps a HTTP response code to the expected response.
// It is not expected from the documentation to necessarily cover all possible HTTP response codes,
// since they may not be known in advance. However, it is expected from the documentation to cover
// a successful operation response and any known errors.
//
// The `default` can be used a default response object for all HTTP codes that are not covered
// individually by the specification.
//
// The `Responses Object` MUST contain at least one response code, and it SHOULD be the response
// for a successful operation call.
//
// For more information: http://goo.gl/8us55a#responsesObject
type Responses struct {
	VendorExtensible
	ResponsesProps
}

// JSONLookup implements an interface to customize json pointer lookup
func (r Responses) JSONLookup(token string) (interface{}, error) {
	if token == "default" {
		return r.Default, nil
	}
	if ex, ok := r.Extensions[token]; ok {
		return &ex, nil
	}
	if i, err := strconv.Atoi(token); err == nil {
		if scr, ok := r.StatusCodeResponses[i]; ok {
			return scr, nil
		}
	}
	return nil, fmt.Errorf("object has no field %q", token)
}

// UnmarshalJSON hydrates this items instance with the data from JSON
func (r *Responses) UnmarshalJSON(data []byte) error {
	if err := json.Unmarshal(data, &r.ResponsesProps); err != nil {
		return err
	}
	if err := json.Unmarshal(data, &r.VendorExtensible); err != nil {
		return err
	}
	if reflect.DeepEqual(ResponsesProps{}, r.ResponsesProps) {
		r.ResponsesProps = ResponsesProps{}
	}
	return nil
}

// MarshalJSON converts this items object to JSON
func (r Responses) MarshalJSON() ([]byte, error) {
	b1, err := json.Marshal(r.ResponsesProps)
	if err != nil {
		return nil, err
	}
	b2, err := json.Marshal(r.VendorExtensible)
	if err != nil {
		return nil, err
	}
	concated := swag.ConcatJSON(b1, b2)
	return concated, nil
}

// ResponsesProps describes all responses for an operation.
// It tells what is the default response and maps all responses with a
// HTTP status code.
type ResponsesProps struct {
	Default             *Response
	StatusCodeResponses map[int]Response
}

// MarshalJSON marshals responses as JSON
func (r ResponsesProps) MarshalJSON() ([]byte, error) {
	toser := map[string]Response{}
	if r.Default != nil {
		toser["default"] = *r.Default
	}
	for k, v := range r.StatusCodeResponses {
		toser[strconv.Itoa(k)] = v
	}
	return json.Marshal(toser)
}

// UnmarshalJSON unmarshals responses from JSON
func (r *ResponsesProps) UnmarshalJSON(data []byte) error {
	var res map[string]Response
	if err := json.Unmarshal(data, &res); err != nil {
		return nil
	}
	if v, ok := res["default"]; ok {
		r.Default = &v
		delete(res, "default")
	}
	for k, v := range res {
		if nk, err := strconv.Atoi(k); err == nil {
			if r.StatusCodeResponses == nil {
				r.StatusCodeResponses = map[int]Response{}
			}
			r.StatusCodeResponses[nk] = v
		}
	}
	return nil
}

Current_dir [ NOT WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
25 Jan 2024 4.43 PM
root / root
0755
.github
--
25 Jan 2024 4.43 PM
root / root
0555
fixtures
--
25 Jan 2024 4.43 PM
root / root
0555
schemas
--
25 Jan 2024 4.43 PM
root / root
0555
.editorconfig
0.526 KB
25 Jan 2024 4.43 PM
root / root
0444
.gitignore
0.024 KB
25 Jan 2024 4.43 PM
root / root
0444
.golangci.yml
0.621 KB
25 Jan 2024 4.43 PM
root / root
0444
CODE_OF_CONDUCT.md
3.157 KB
25 Jan 2024 4.43 PM
root / root
0444
LICENSE
11.092 KB
25 Jan 2024 4.43 PM
root / root
0444
README.md
2.114 KB
25 Jan 2024 4.43 PM
root / root
0444
appveyor.yml
1.261 KB
25 Jan 2024 4.43 PM
root / root
0444
auth_test.go
4.577 KB
25 Jan 2024 4.43 PM
root / root
0444
bindata.go
24.402 KB
25 Jan 2024 4.43 PM
root / root
0444
cache.go
2.507 KB
25 Jan 2024 4.43 PM
root / root
0444
cache_test.go
0.66 KB
25 Jan 2024 4.43 PM
root / root
0444
circular_test.go
9.746 KB
25 Jan 2024 4.43 PM
root / root
0444
contact_info.go
1.574 KB
25 Jan 2024 4.43 PM
root / root
0444
contact_info_test.go
1.422 KB
25 Jan 2024 4.43 PM
root / root
0444
debug.go
1.272 KB
25 Jan 2024 4.43 PM
root / root
0444
debug_test.go
1.293 KB
25 Jan 2024 4.43 PM
root / root
0444
errors.go
0.881 KB
25 Jan 2024 4.43 PM
root / root
0444
expander.go
16.719 KB
25 Jan 2024 4.43 PM
root / root
0444
expander_test.go
40.121 KB
25 Jan 2024 4.43 PM
root / root
0444
external_docs.go
0.896 KB
25 Jan 2024 4.43 PM
root / root
0444
external_docs_test.go
1.045 KB
25 Jan 2024 4.43 PM
root / root
0444
go.mod
0.236 KB
25 Jan 2024 4.43 PM
root / root
0444
go.sum
3.695 KB
25 Jan 2024 4.43 PM
root / root
0444
header.go
4.943 KB
25 Jan 2024 4.43 PM
root / root
0444
header_test.go
4.348 KB
25 Jan 2024 4.43 PM
root / root
0444
helpers_spec_test.go
3.971 KB
25 Jan 2024 4.43 PM
root / root
0444
helpers_test.go
4.854 KB
25 Jan 2024 4.43 PM
root / root
0444
info.go
4.256 KB
25 Jan 2024 4.43 PM
root / root
0444
info_test.go
2.407 KB
25 Jan 2024 4.43 PM
root / root
0444
items.go
5.755 KB
25 Jan 2024 4.43 PM
root / root
0444
items_test.go
4.494 KB
25 Jan 2024 4.43 PM
root / root
0444
license.go
1.48 KB
25 Jan 2024 4.43 PM
root / root
0444
license_test.go
1.322 KB
25 Jan 2024 4.43 PM
root / root
0444
normalizer.go
6.241 KB
25 Jan 2024 4.43 PM
root / root
0444
normalizer_nonwindows.go
1.191 KB
25 Jan 2024 4.43 PM
root / root
0444
normalizer_test.go
16.808 KB
25 Jan 2024 4.43 PM
root / root
0444
normalizer_windows.go
5.146 KB
25 Jan 2024 4.43 PM
root / root
0444
operation.go
10.751 KB
25 Jan 2024 4.43 PM
root / root
0444
operation_test.go
9.549 KB
25 Jan 2024 4.43 PM
root / root
0444
parameter.go
10.344 KB
25 Jan 2024 4.43 PM
root / root
0444
parameters_test.go
4.756 KB
25 Jan 2024 4.43 PM
root / root
0444
path_item.go
2.596 KB
25 Jan 2024 4.43 PM
root / root
0444
path_item_test.go
2.42 KB
25 Jan 2024 4.43 PM
root / root
0444
paths.go
2.571 KB
25 Jan 2024 4.43 PM
root / root
0444
paths_test.go
1.167 KB
25 Jan 2024 4.43 PM
root / root
0444
properties.go
2.403 KB
25 Jan 2024 4.43 PM
root / root
0444
properties_test.go
2.054 KB
25 Jan 2024 4.43 PM
root / root
0444
ref.go
4.167 KB
25 Jan 2024 4.43 PM
root / root
0444
ref_test.go
1.19 KB
25 Jan 2024 4.43 PM
root / root
0444
resolver.go
3.752 KB
25 Jan 2024 4.43 PM
root / root
0444
resolver_test.go
12.791 KB
25 Jan 2024 4.43 PM
root / root
0444
response.go
4.166 KB
25 Jan 2024 4.43 PM
root / root
0444
response_test.go
2.817 KB
25 Jan 2024 4.43 PM
root / root
0444
responses.go
3.619 KB
25 Jan 2024 4.43 PM
root / root
0444
schema.go
18.14 KB
25 Jan 2024 4.43 PM
root / root
0444
schema_loader.go
8.993 KB
25 Jan 2024 4.43 PM
root / root
0444
schema_test.go
6.643 KB
25 Jan 2024 4.43 PM
root / root
0444
security_scheme.go
5.713 KB
25 Jan 2024 4.43 PM
root / root
0444
spec.go
2.18 KB
25 Jan 2024 4.43 PM
root / root
0444
spec_test.go
12.704 KB
25 Jan 2024 4.43 PM
root / root
0444
structs_test.go
3.88 KB
25 Jan 2024 4.43 PM
root / root
0444
swagger.go
11.854 KB
25 Jan 2024 4.43 PM
root / root
0444
swagger_test.go
11.273 KB
25 Jan 2024 4.43 PM
root / root
0444
tag.go
2.235 KB
25 Jan 2024 4.43 PM
root / root
0444
url_go18.go
0.093 KB
25 Jan 2024 4.43 PM
root / root
0444
url_go19.go
0.189 KB
25 Jan 2024 4.43 PM
root / root
0444
validations.go
7.121 KB
25 Jan 2024 4.43 PM
root / root
0444
validations_test.go
2.969 KB
25 Jan 2024 4.43 PM
root / root
0444
xml_object.go
1.928 KB
25 Jan 2024 4.43 PM
root / root
0444
xml_object_test.go
1.938 KB
25 Jan 2024 4.43 PM
root / root
0444

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF