Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getOrganizationDevicesStatuses response of wrong type #50

Open
stephengroat opened this issue Jul 25, 2023 · 9 comments
Open

getOrganizationDevicesStatuses response of wrong type #50

stephengroat opened this issue Jul 25, 2023 · 9 comments
Labels
pending evidence workaround available An available workaround mitigates the impact of this issue.

Comments

@stephengroat
Copy link

Error on GetOrganizationDevicesStatuses unmarshal in OrganizationApi

json: cannot unmarshal object into Go struct field GetOrganizationDevicesStatuses200ResponseInnerComponents.components.powerSupplies of type string

currently marked as array of string in spec

see meraki/dashboard-api-go#18

@TKIPisalegacycipher
Copy link
Collaborator

Hi @stephengroat please mention the specific part of the OAS if you believe there is an issue with the spec so we can investigate. What you've provided so far does not point directly to any section of our OAS.

@stephengroat
Copy link
Author

        "operationId": "getOrganizationDevicesStatuses",
...
                  "components": {
                    "type": "object",
                    "properties": {
                      "powerSupplies": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        },
                        "description": "Power Supplies"
                      }
                    },
                    "description": "Components"
                  },

as seen in the error message

json: cannot unmarshal object into Go struct field GetOrganizationDevicesStatuses200ResponseInnerComponents.components.powerSupplies of type string

powerSupplies is showing as type string, instead of an array of string

@stephengroat-dd
Copy link

👋 wondering if anymore information is needed to triage

@jyoung15
Copy link

jyoung15 commented Aug 16, 2023

I ran into this issue as well. It seems the API returns an object array instead of a string array. Example:

{
  "powerSupplies": [
    {
      "slot": 1,
      "serial": "XXXX-XXXX-XXXX",
      "model": "PWR-MS320-1025WAC",
      "status": "powering",
      "poe": {
        "unit": "watts",
        "maximum": 740
      }
    },
    {
      "slot": 2,
      "serial": "",
      "model": "",
      "status": "disconnected",
      "poe": {
        "unit": "watts",
        "maximum": 0
      }
    }
  ]
}

Until the spec can be corrected, the following can be applied to address meraki/dashboard-api-go#18:

diff --git a/client/model_get_organization_devices_statuses_200_response_inner_components.go b/client/model_get_organization_devices_statuses_200_response_inner_components.go
index cae93d96..c38caf6b 100644
--- a/client/model_get_organization_devices_statuses_200_response_inner_components.go
+++ b/client/model_get_organization_devices_statuses_200_response_inner_components.go
@@ -17,10 +17,23 @@ import (
 // checks if the GetOrganizationDevicesStatuses200ResponseInnerComponents type satisfies the MappedNullable interface at compile time
 var _ MappedNullable = &GetOrganizationDevicesStatuses200ResponseInnerComponents{}

+type Poe struct {
+       Unit    string `json:"unit"`
+       Maximum int    `json:"maximum"`
+}
+
+type PowerSupply struct {
+       Slot   int    `json:"slot"`
+       Serial string `json:"serial"`
+       Model  string `json:"model"`
+       Status string `json:"status"`
+       Poe    Poe    `json:"poe"`
+}
+
 // GetOrganizationDevicesStatuses200ResponseInnerComponents Components
 type GetOrganizationDevicesStatuses200ResponseInnerComponents struct {
        // Power Supplies
-       PowerSupplies []string `json:"powerSupplies,omitempty"`
+       PowerSupplies []PowerSupply `json:"powerSupplies,omitempty"`
 }

 // NewGetOrganizationDevicesStatuses200ResponseInnerComponents instantiates a new GetOrganizationDevicesStatuses200ResponseInnerComponents object
@@ -41,9 +54,9 @@ func NewGetOrganizationDevicesStatuses200ResponseInnerComponentsWithDefaults() *
 }

 // GetPowerSupplies returns the PowerSupplies field value if set, zero value otherwise.
-func (o *GetOrganizationDevicesStatuses200ResponseInnerComponents) GetPowerSupplies() []string {
+func (o *GetOrganizationDevicesStatuses200ResponseInnerComponents) GetPowerSupplies() []PowerSupply {
        if o == nil || IsNil(o.PowerSupplies) {
-               var ret []string
+               var ret []PowerSupply
                return ret
        }
        return o.PowerSupplies
@@ -51,7 +64,7 @@ func (o *GetOrganizationDevicesStatuses200ResponseInnerComponents) GetPowerSuppl

 // GetPowerSuppliesOk returns a tuple with the PowerSupplies field value if set, nil otherwise
 // and a boolean to check if the value has been set.
-func (o *GetOrganizationDevicesStatuses200ResponseInnerComponents) GetPowerSuppliesOk() ([]string, bool) {
+func (o *GetOrganizationDevicesStatuses200ResponseInnerComponents) GetPowerSuppliesOk() ([]PowerSupply, bool) {
        if o == nil || IsNil(o.PowerSupplies) {
                return nil, false
        }
@@ -68,7 +81,7 @@ func (o *GetOrganizationDevicesStatuses200ResponseInnerComponents) HasPowerSuppl
 }

 // SetPowerSupplies gets a reference to the given []string and assigns it to the PowerSupplies field.
-func (o *GetOrganizationDevicesStatuses200ResponseInnerComponents) SetPowerSupplies(v []string) {
+func (o *GetOrganizationDevicesStatuses200ResponseInnerComponents) SetPowerSupplies(v []PowerSupply) {
        o.PowerSupplies = v
 }

@TKIPisalegacycipher
Copy link
Collaborator

Hello @stephengroat, @stephengroat-dd and @jyoung15:

Do you have this issue if you use instead the following endpoints for the same information? FWIW the getOrganizationDevicesStatuses endpoint has better alternatives:

If you are only concerned with right-now status of devices: getOrganizationDevicesAvailabilities
If you are only concerned with right-now power supply statuses: getOrganizationDevicesPowerModulesStatusesByDevice
If you are polling device status over time, then this third endpoint is more efficient: getOrganizationDevicesAvailabilitiesChangeHistory
If you need uplinks addresses, then this is the best way to get that information: getOrganizationDevicesUplinksAddressesByDevice

I'm not aware of any schema issues on the aforementioned endpoints.

@stephengroat
Copy link
Author

stephengroat commented Dec 6, 2023

Sorry, this is the only endpoint that works for my use case.

Is there going to be any fix upcoming for this bug?

@TKIPisalegacycipher
Copy link
Collaborator

Hi @stephengroat, what's the use case?

@stephengroat-dd
Copy link

@TKIPisalegacycipher We collect every IP that meraki records on every device for historical evidence

@TKIPisalegacycipher
Copy link
Collaborator

Thanks @stephengroat-dd! This operation is the best way to get that information: getOrganizationDevicesUplinksAddressesByDevice

@TKIPisalegacycipher TKIPisalegacycipher added the workaround available An available workaround mitigates the impact of this issue. label Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending evidence workaround available An available workaround mitigates the impact of this issue.
Projects
None yet
Development

No branches or pull requests

4 participants