WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

error when response has no content type is very vague #79

@barbeque-squared

Description

@barbeque-squared

Run npx apib2swagger -i blueprint.apib --open-api-3 on this apib:

FORMAT: 1A
HOST: http://example.org

# My Title

This is some blueprint

# Group A Group

## Some URL [/some/url]

### Some super awesome endpoint [PUT]
+ Request
  + Attributes (object)
+ Response 200
  + Attributes (object)

Expected result: not sure actually (see details)

Actual result:

TypeError: Cannot read properties of undefined (reading 'value')
    at setResponseSchema (.../node_modules/apib2swagger/src/responses.js:92:28)

Details:
I can make it work by either:

  • changing the if to if (contentTypeHeader === undefined || !contentTypeHeader.value)
  • Response 200 (application/json)

but I can't figure out whether

  1. the response should always have a content type, or
  2. the response does not necessarily need to have a content type

because on the one hand there's an if check that I think is just supposed to return if it doesn't have a content type? The API blueprint docs would also suggest that this is valid?

on the other I'm also fine with having to explicitly set them since it's not bad to do so, but in that case the error should be made clearer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions