Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nullable custom types break OpenAPI3 export #66

Closed
reieRMeister opened this issue May 9, 2022 · 2 comments
Closed

Nullable custom types break OpenAPI3 export #66

reieRMeister opened this issue May 9, 2022 · 2 comments

Comments

@reieRMeister
Copy link

Nominal

Rendering an API Blueprint document to OpenAPI3 with flag --open-api-3 converts an input property like this:

    + images (required, nullable, ImagesType)

into this:

    images:
        type: ImagesType
        nullable: true
        …

Actual

Rendering an API Blueprint document to OpenAPI3 with flag --open-api-3 converts an input property like this:

    + images (required, nullable, ImagesType)

results in this error stack trace:

Error
    at Object.<anonymous> (/usr/local/lib/node_modules/apib2swagger/node_modules/json-schema-to-openapi-schema/index.js:8:30)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/apib2swagger/src/requests.js:4:19)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10) {
  name: 'InvalidTypeError',
  message: 'Type "null" is not a valid type'
}

Remarks

#65 is related but only shows a workaround which is not useful if you want to use a certain type to be not nullable and nullable in different areas of your API.

@kminami
Copy link
Owner

kminami commented May 16, 2022

Thank you for reporting!
I have fixed this bug at v1.14.3.
Please confirm.

Output looks like:

images:
  oneOf:
    - $ref: '#/components/schemas/ImagesType'
    - nullable: true

@kminami kminami reopened this May 16, 2022
@reieRMeister
Copy link
Author

Looks good to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants