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

Handle "type" that contain a single-element array #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mars
Copy link

@mars mars commented Jun 28, 2018

No description provided.

@kibertoad
Copy link

@philsturgeon Any concerns about this PR?..

@@ -4,7 +4,7 @@ const convert = require('../');
const should = require('should');
const getSchema = require('./helpers').getSchema;

['basic', 'address', 'calendar'].forEach(test => {
['basic', 'address', 'calendar', 'single-type-arrays'].forEach(test => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These examples were taken from JSON Schema and were not meant to be the home for specific tests.

Maybe this test file would be a better home for testing this functionality? https://github.com/wework/json-schema-to-openapi-schema/blob/master/test/invalid_types.test.js

Copy link
Contributor

@philsturgeon philsturgeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this PR highlights an existing bug in this package.

Changing that would be appreciated, while we're here.

if (schema.type.length > 2 || (schema.type.length > 1 && !schema.type.includes('null'))) {
// could be
if (schema.type.length > 1 && !schema.type.includes('null')) {

The first would allow type: ['integer', 'string'] which is definitely not allowed.

I've got some other notes about the way it's been tested. If those things can be resolved then I'll be happy to merge. Thank you!

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

Successfully merging this pull request may close these issues.

3 participants