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

Conversion fails – because of nullable attributes? #76

@R3gi

Description

@R3gi

When I try to convert the API Blueprint docs to Open API v3.0, the script fails.
cat apiary.apib | npx apib2swagger --yaml --open-api-3 > swagger.yaml

TypeError: Cannot read properties of undefined (reading 'value')
    at setResponseSchema (/Users/userme/.npm/_npx/b8304055354efd5a/node_modules/apib2swagger/src/responses.js:92:28)
    at module.exports.processResponses (/Users/userme/.npm/_npx/b8304055354efd5a/node_modules/apib2swagger/src/responses.js:181:29)
    at swaggerOperation (/Users/userme/.npm/_npx/b8304055354efd5a/node_modules/apib2swagger/index.js:160:22)
    at swaggerPaths (/Users/userme/.npm/_npx/b8304055354efd5a/node_modules/apib2swagger/index.js:148:60)
    at /Users/userme/.npm/_npx/b8304055354efd5a/node_modules/apib2swagger/index.js:71:17
    at Array.forEach (<anonymous>)
    at /Users/userme/.npm/_npx/b8304055354efd5a/node_modules/apib2swagger/index.js:62:26
    at Array.forEach (<anonymous>)
    at module.exports.convertParsed (/Users/userme/.npm/_npx/b8304055354efd5a/node_modules/apib2swagger/index.js:57:8)
    at exports.convert (/Users/userme/.npm/_npx/b8304055354efd5a/node_modules/apib2swagger/index.js:200:23)

When I run the script without the --open-api-3 flag, the file is converted, but IDE indicates "Property 'oneOf' is not allowed" errors and the official SwaggerEditor detects problems for all the nullable - 'null' properties. I guess the problem could be caused by the nullable values which are not handled properly.

Generated Open API v2.0:

      homeAddress:
        oneOf:
          - $ref: '#/definitions/Address'
            description: homeAddress, response only
          - type: 'null'

The source document has more than 1300 lines and is private so I cannot post it. It is valid according the API blueprint specs.

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