Skip to content

types in definitions are not converted #5

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

Closed
hugomallet opened this issue Apr 20, 2018 · 1 comment
Closed

types in definitions are not converted #5

hugomallet opened this issue Apr 20, 2018 · 1 comment

Comments

@hugomallet
Copy link

Hi,

Types are not converted if they are defined in the definitions field.

Simple example to reproduce :

const toOpenApi = require('json-schema-to-openapi-schema');
const { inspect } = require('util');

const successfulSchema = {
	$schema: 'http://json-schema.org/draft-04/schema#',
	type: 'object',
	properties: {
		issue: {
			type: ['string', 'null']
		}
	}
};

const failingSchema = {
	$schema: 'http://json-schema.org/draft-04/schema#',
	type: 'object',
	properties: {
		issue: { $ref: '#/definitions/issue' }
	},
	definitions: {
		issue: {
			type: ['string', 'null']
		}
	}
};

const successfullyConvertedSchema = toOpenApi(successfulSchema);
const failedConvertedSchema = toOpenApi(failingSchema);

console.log('SUCCESS');
console.log(inspect(successfullyConvertedSchema, { compact: false, depth: 3 }));
console.log('FAILURE');
console.log(inspect(failedConvertedSchema, { compact: false, depth: 3 }));

Expected result : failingSchema should be converted

Hugo

@hugomallet hugomallet changed the title types in definitions not converted types in definitions are not converted Apr 20, 2018
@philsturgeon
Copy link
Contributor

Hey there! Sorry but its not about definitions, it's just that this tool does not resolve $ref. There are tools around that do, and you should use those before passing the result to this document.

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