ScottLogic / openapi-forge

⚒️🔥 Effortlessly create OpenAPI clients, in a range of languages, from the fiery furnace of our forge
8 stars 7 forks source link

TypeScript generator assumes all responses are JSON #167

Closed ColinEberhardt closed 1 year ago

ColinEberhardt commented 1 year ago

See: https://github.com/ScottLogic/openapi-forge-typescript/blob/main/template/fetch.ts#L8

This is probably true for the JS generator also

ColinEberhardt commented 1 year ago

Looking at the spec, despite the media type specifying application/json, primitive values are indeed acceptable https://swagger.io/specification/#schema-object

ColinEberhardt commented 1 year ago

After further exploration, this is not a bug. Strings, when returned from the API, should be quoted, making them valid JSON. For example "hello" is valid JSON.

The Petstore example API server has a bug relating to this. I've raised a PR:

https://github.com/swagger-api/swagger-petstore/pull/95