Refactored swagger.yml for fewer dns requests

Signed-off-by: Chris Green <34572557+cgreen12@users.noreply.github.com>
This commit is contained in:
Chris Green
2019-06-04 02:54:23 -04:00
parent 74ffcc8d2e
commit bbac97c17e
5 changed files with 73 additions and 31 deletions
+26
View File
@@ -22,6 +22,9 @@ type CheckAllResults struct {
// o k
OK *bool `json:"OK,omitempty"`
// dns results
DNSResults map[string]DNSResults `json:"dnsResults,omitempty"`
// hosts
Hosts []*CheckAllResultsHostsItems0 `json:"hosts"`
@@ -39,6 +42,10 @@ type CheckAllResults struct {
func (m *CheckAllResults) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateDNSResults(formats); err != nil {
res = append(res, err)
}
if err := m.validateHosts(formats); err != nil {
res = append(res, err)
}
@@ -53,6 +60,25 @@ func (m *CheckAllResults) Validate(formats strfmt.Registry) error {
return nil
}
func (m *CheckAllResults) validateDNSResults(formats strfmt.Registry) error {
if swag.IsZero(m.DNSResults) { // not required
return nil
}
for k := range m.DNSResults {
if val, ok := m.DNSResults[k]; ok {
if err := val.Validate(formats); err != nil {
return err
}
}
}
return nil
}
func (m *CheckAllResults) validateHosts(formats strfmt.Registry) error {
if swag.IsZero(m.Hosts) { // not required
-23
View File
@@ -21,9 +21,6 @@ type PingResults struct {
// Format: date-time
BootTime strfmt.DateTime `json:"boot_time,omitempty"`
// dns results
DNSResults DNSResults `json:"dnsResults,omitempty"`
// received
Received *CallStats `json:"received,omitempty"`
}
@@ -36,10 +33,6 @@ func (m *PingResults) Validate(formats strfmt.Registry) error {
res = append(res, err)
}
if err := m.validateDNSResults(formats); err != nil {
res = append(res, err)
}
if err := m.validateReceived(formats); err != nil {
res = append(res, err)
}
@@ -63,22 +56,6 @@ func (m *PingResults) validateBootTime(formats strfmt.Registry) error {
return nil
}
func (m *PingResults) validateDNSResults(formats strfmt.Registry) error {
if swag.IsZero(m.DNSResults) { // not required
return nil
}
if err := m.DNSResults.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("dnsResults")
}
return err
}
return nil
}
func (m *PingResults) validateReceived(formats strfmt.Registry) error {
if swag.IsZero(m.Received) { // not required
+23
View File
@@ -24,6 +24,9 @@ type PodResult struct {
// o k
OK *bool `json:"OK,omitempty"`
// dns results
DNSResults DNSResults `json:"dnsResults,omitempty"`
// error
Error string `json:"error,omitempty"`
@@ -45,6 +48,10 @@ func (m *PodResult) Validate(formats strfmt.Registry) error {
res = append(res, err)
}
if err := m.validateDNSResults(formats); err != nil {
res = append(res, err)
}
if err := m.validateResponse(formats); err != nil {
res = append(res, err)
}
@@ -68,6 +75,22 @@ func (m *PodResult) validateHostIP(formats strfmt.Registry) error {
return nil
}
func (m *PodResult) validateDNSResults(formats strfmt.Registry) error {
if swag.IsZero(m.DNSResults) { // not required
return nil
}
if err := m.DNSResults.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("dnsResults")
}
return err
}
return nil
}
func (m *PodResult) validateResponse(formats strfmt.Registry) error {
if swag.IsZero(m.Response) { // not required
+18 -6
View File
@@ -143,6 +143,12 @@ func init() {
"type": "boolean",
"default": false
},
"dnsResults": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/DnsResults"
}
},
"hosts": {
"type": "array",
"items": {
@@ -222,9 +228,6 @@ func init() {
"type": "string",
"format": "date-time"
},
"dnsResults": {
"$ref": "#/definitions/DnsResults"
},
"received": {
"$ref": "#/definitions/CallStats"
}
@@ -241,6 +244,9 @@ func init() {
"type": "boolean",
"default": false
},
"dnsResults": {
"$ref": "#/definitions/DnsResults"
},
"error": {
"type": "string"
},
@@ -386,6 +392,12 @@ func init() {
"type": "boolean",
"default": false
},
"dnsResults": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/DnsResults"
}
},
"hosts": {
"type": "array",
"items": {
@@ -465,9 +477,6 @@ func init() {
"type": "string",
"format": "date-time"
},
"dnsResults": {
"$ref": "#/definitions/DnsResults"
},
"received": {
"$ref": "#/definitions/CallStats"
}
@@ -484,6 +493,9 @@ func init() {
"type": "boolean",
"default": false
},
"dnsResults": {
"$ref": "#/definitions/DnsResults"
},
"error": {
"type": "string"
},
+6 -2
View File
@@ -31,8 +31,6 @@ definitions:
type: string
received:
$ref: '#/definitions/CallStats'
dnsResults:
$ref: '#/definitions/DnsResults'
PodResult:
type: object
properties:
@@ -44,6 +42,8 @@ definitions:
format: ipv4
response:
$ref: '#/definitions/PingResults'
dnsResults:
$ref: '#/definitions/DnsResults'
error:
type: string
status-code:
@@ -96,6 +96,10 @@ definitions:
podIP:
type: string
format: ipv4
dnsResults:
type: object
additionalProperties:
$ref: '#/definitions/DnsResults'
responses:
type: object
additionalProperties: