commercetools / commercetools-api-reference

commercetools API reference documentation
http://docs.commercetools.com/
57 stars 27 forks source link

localeProjection mistyped in /oas/openapi.yaml #269

Closed DJHunn39 closed 2 years ago

DJHunn39 commented 2 years ago

tl;dr - I can't send multiple localeProjection parameters in a request using the TS SDK because localeProjection is typed as a string instead of an array

According to CommerceTools API documentation:

localeProjection - String - Optional IETF language tag . Enables locale based projection. To set more than one locale, use this query parameter multiple times.

This means that a valid URI including multiple localeProjections would include, for examplelocaleProjection=en-gb&localeProjection=en-us.

However, the openapi.yaml schema for this field dictates that this field must be a string:

From the raw file itself:

- name: localeProjection
   in: query
   required: false
   style: form
   schema:
       type: "string"

I believe this is the cause of an issue in the TypeScript SDK where it's not possible to make a GET request including multiple localeProjection query parameters without casting around the type to force it to work, i.e I want to make a get request with 2 localeProjections like so:

.get({
  queryArgs: {
    localeProjection: ['en-gb', 'en-us'],
    ...
  }
});

Right now I can't do this as the type of localeProjection must be a string.

I believe changing schema.type for all localeProjection parameter definitions from string to array will resolve the issue.

jenschude commented 2 years ago

Thanks for the report. I opened a PR in the upstream repository with a fix

jenschude commented 2 years ago

The change is now applied to the openapi.yml.

The SDKs may not be immediately released with a fix

DJHunn39 commented 2 years ago

Thanks for the quick reaction to this!

jenschude commented 2 years ago

SDKs with fixes have been released

Thanks for the report