Closed GabrielPadureanu closed 2 years ago
Hi,
I'm using as a value of a key a pattern with a schema object.
I would expect that a component is created for the schema referenced in the additional parameters.
expect
const innerSchema = Joi.object().keys({ key: Joi.any(), }).meta({ className: 'innerSchema' });
id: Joi.object().pattern( /^/, innerSchema, ), }).meta({ className: 'patternSchema' });
const componentsPatternSchema = j2s(patternSchema as Schema).components; componentsPatternSchema is
const componentsPatternSchema = j2s(patternSchema as Schema).components;
componentsPatternSchema
{ "schemas": { "patternSchema": { "type": "object", "properties": { "id": { "type": "object", "properties": {}, "additionalProperties": { "$ref": "#/components/schemas/innerSchema" } } }, "additionalProperties": false } } }
but no component was created for what is referenced in the additonalProperties.
Using a schema as a value for a key of a schema will create the component as expected
const noPatternSchema = Joi.object().keys({ id: innerSchema }).meta({ className: 'noPatternSchema' }); const componentsNoPatternSchema = j2s(noPatternSchema as Schema).components;
componentsNoPatternSchema is
componentsNoPatternSchema
"schemas": { "innerSchema": { "type": "object", "properties": { "key": {} }, "additionalProperties": false }, "noPatternSchema": { "type": "object", "properties": { "id": { "$ref": "#/components/schemas/innerSchema" } }, "additionalProperties": false } } }
Is this an issue or another approach is required in order to get the expected output?
Thank you for any insight provided!
joi-to-swagger version 6.1.0
I think that was an oversight when #94 was implemented. Should be fixed now in 6.1.1.
Thank you for your prompt answer and solution!
Hi,
I'm using as a value of a key a pattern with a schema object.
I would
expect
that a component is created for the schema referenced in the additional parameters.const componentsPatternSchema = j2s(patternSchema as Schema).components;
componentsPatternSchema
isbut no component was created for what is referenced in the additonalProperties.
Using a schema as a value for a key of a schema will create the component as expected
componentsNoPatternSchema
isIs this an issue or another approach is required in order to get the expected output?
Thank you for any insight provided!
joi-to-swagger version 6.1.0