Skip to content

Issue with oats-axios-adapter when endpoint has no headers and content-type is DIFFERENT from application/json #373

@danyg

Description

@danyg

When using oats-axios-adapter with endpoints that don't define any headers and use content type different from application/json, i.e. only application/x-www-form-urlencoded.

The type for the endpoint headers is void THEN the generated Axios client fails to perform the call as it is expecting that the property headers be initialized as an object which is not.

The error occurs in /packages/oats-axios-adapter/index.ts#L90 as arg.headers is not checked for emptiness when construction the request headers from arg.headers and data.contentType

Steps to reproduce

  • Use the the packages/oats-mirage-adapter/test-app
  • Change or add content application/x-www-form-urlencoded to #/components/requestBodies/PostBody and try to generate an axios client with it.
  • make a post call with such client

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions