AmadeusITGroup / otter

The Otter project is a highly modular framework whose goal is to provide a common platform to accelerate and facilitate the development of runtime customizable Angular based Web Applications
https://amadeusitgroup.github.io/otter/
BSD 3-Clause "New" or "Revised" License
51 stars 39 forks source link

[Bug]: invalid content-type when generating a POST request with openapi generator #788

Closed quentinderoubaix closed 1 year ago

quentinderoubaix commented 1 year ago

Package name

generator-sdk

Package version

Latest alpha

Reproduction steps

Generate an api library using the newly schematic ng generate sdk and use a spec yaml file that contains a POST request with consumes: -application/x-www-form-urlencoded

Launch the typescript services / models generation.

Current result

Observe that the typescript api will contain the following:

  const headers: { [key: string]: string | undefined } = { 
    'Content-Type': metadata?.headerContentType || 'application/json',
    ...(metadataHeaderAccept ? {'Accept': metadataHeaderAccept} : {})
  };

Expected result

The part above should be:

  const headers: { [key: string]: string | undefined } = { 
    'Content-Type': metadata?.headerContentType || 'application/x-www-form-urlencoded',
    ...(metadataHeaderAccept ? {'Accept': metadataHeaderAccept} : {})
  };

Additional comments

This is due to a regression in the api.mustache file when switching to the openapi generator. We are using HeaderJsonMimeType custom lambda but giving an invalid input.

kpanot commented 1 year ago

The internal SDK may need to be re-generated with the latest version of the generator including the support of the consumes headers.

mrednic-1A commented 1 year ago

Thanks @quentinderoubaix for raising the point and for your contribution. We have included your fix in the version 9.1 of the ama-sdk-schematics (sdk generator) package.