grokify / go-ringcentral-engage

RingCentral Engage Digital / Dimelo SDK for Go - https://www.dimelo.com - https://engage-api-docs.rtfd.org
MIT License
4 stars 3 forks source link

Locales and Timezones API response returns wrong type #2

Closed grokify closed 5 years ago

grokify commented 5 years ago

The /1.0/locales API returns an Array of objects, but it appears OpenAPI generator atempts to return a map[string]interface{} which results a JSON unmarshal error.

Specification:

        "responses":{
          "200":{
            "description":"List of all locales",
            "schema":{
              "type":"array",
              "items":{
                "$ref":"#/definitions/Locale"
              }
            }
          }
        }

Generated Go Function:

func (a *LocalesApiService) GetAllLocales(ctx context.Context) (map[string]interface{}, *http.Response, error) {

Error:

json: cannot unmarshal array into Go value of type map[string]interface {}

Raw response:

[{"name":"Afrikaans","code":"af","interface":false},{"name":"العربية (Arabic)","code":"ar","interface":false},{"name":"Беларуская (Belarusian)","code":"be","interface":false},{"name":"български (Bulgarian)","code":"bg","interface":false},{"name":"বাংলা (Bengali)","code":"bn","interface":false},{"name":"Català (Catalan)","code":"ca","interface":false},{"name":"کوردی (Central Kurdish)","code":"ckb","interface":false},{"name":"čeština (Czech)","code":"cs","interface":false},{"name":"Cymraeg","code":"cy","interface":false},{"name":"Dansk","code":"da","interface":false},{"name":"Deutsch","code":"de","interface":true},{"name":"Ελληνικά (Greek)","code":"el","interface":false},{"name":"English","code":"en","interface":true},{"name":"Esperanto","code":"eo","interface":false},{"name":"Español","code":"es","interface":true},{"name":"Eesti","code":"et","interface":false},{"name":"فارسی (Persian)","code":"fa","interface":false},{"name":"Suomi","code":"fi","interface":false},{"name":"Français","code":"fr","interface":true},{"name":"Gaeilge","code":"ga","interface":false},{"name":"Galego","code":"gl","interface":false},{"name":"हिन्दी (Hindi)","code":"hi","interface":false},{"name":"Hrvatski","code":"hr","interface":false},{"name":"Kreyòl Ayisyen (Haitian Creole)","code":"ht","interface":false},{"name":"Magyar","code":"hu","interface":false},{"name":"Bahasa Indonesia","code":"id","interface":false},{"name":"Íslenska (Icelandic)","code":"is","interface":false},{"name":"Italiano","code":"it","interface":false},{"name":"עברית (Hebrew)","code":"iw","interface":false},{"name":"日本語 (Japanese)","code":"ja","interface":false},{"name":"Khmer","code":"km","interface":false},{"name":"한국어 (Korean)","code":"ko","interface":false},{"name":"Lietuvių (Lithuanian)","code":"lt","interface":false},{"name":"Latviešu (Latvian)","code":"lv","interface":false},{"name":"Malagasy","code":"mg","interface":false},{"name":"македонски (Macedonian)","code":"mk","interface":false},{"name":"Bahasa Malaysia","code":"ms","interface":false},{"name":"Malti","code":"mt","interface":false},{"name":"Burmese","code":"my","interface":false},{"name":"Nepali","code":"ne","interface":false},{"name":"Nederlands","code":"nl","interface":true},{"name":"Norsk","code":"no","interface":false},{"name":"Polski","code":"pl","interface":false},{"name":"Português","code":"pt","interface":false},{"name":"Română","code":"ro","interface":false},{"name":"русский (Russian)","code":"ru","interface":false},{"name":"සිංහල (Sinhalese)","code":"si","interface":false},{"name":"slovenčina (Slovak)","code":"sk","interface":false},{"name":"slovenščina (Slovene)","code":"sl","interface":false},{"name":"Shqip","code":"sq","interface":false},{"name":"српски (Serbian)","code":"sr","interface":false},{"name":"svenska","code":"sv","interface":false},{"name":"Kiswahili","code":"sw","interface":false},{"name":"ภาษาไทย (Thai)","code":"th","interface":false},{"name":"Filipino","code":"tl","interface":false},{"name":"Türkçe (Turkish)","code":"tr","interface":false},{"name":"українська (Ukrainian)","code":"uk","interface":false},{"name":"اردو (Urdu)","code":"ur","interface":false},{"name":"Tiếng Việt (Vietnamese)","code":"vi","interface":false},{"name":"אידיש (Yiddish)","code":"yi","interface":false},{"name":"中文(简体) (Chinese)","code":"zh","interface":false},{"name":"中文(繁體) (Taiwanese Mandarin)","code":"zh-TW","interface":false}]

grokify commented 5 years ago

Resolved by migrating to OAS 3.0 specs.