Skip to content

Commit

Permalink
fix(ns-openapi-3-1): fix bugs in Schema Object refracting
Browse files Browse the repository at this point in the history
Closes #337
  • Loading branch information
char0n committed Apr 9, 2021
1 parent 88cd7e1 commit e9e0cd0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import stampit from 'stampit';
import { ArrayElement } from 'apidom';
import { ObjectElement, BREAK } from 'apidom';

import FallbackVisitor from '../../FallbackVisitor';
import { appendMetadata } from '../../../metadata';

const DependentRequiredVisitor = stampit(FallbackVisitor, {
methods: {
ArrayElement(arrayElement: ArrayElement) {
this.element = arrayElement.clone();
ObjectElement(objectElement: ObjectElement) {
this.element = objectElement.clone();

appendMetadata(['json-schema-dependentRequired'], this.element);

return BREAK;
},
},
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import stampit from 'stampit';
import { ArrayElement } from 'apidom';
import { ArrayElement, BREAK } from 'apidom';

import FallbackVisitor from '../../FallbackVisitor';
import { appendMetadata } from '../../../metadata';
Expand All @@ -10,6 +10,8 @@ const ExamplesVisitor = stampit(FallbackVisitor, {
this.element = arrayElement.clone();

appendMetadata(['json-schema-examples'], this.element);

return BREAK;
},
},
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import stampit from 'stampit';
import { ArrayElement } from 'apidom';
import { ArrayElement, BREAK } from 'apidom';

import FallbackVisitor from '../../FallbackVisitor';
import { appendMetadata } from '../../../metadata';
Expand All @@ -10,6 +10,8 @@ const RequiredVisitor = stampit(FallbackVisitor, {
this.element = arrayElement.clone();

appendMetadata(['json-schema-required'], this.element);

return BREAK;
},
},
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
import stampit from 'stampit';
import { ObjectElement, BREAK } from 'apidom';
import { always } from 'ramda';

import SchemaElement from '../../../../elements/Schema';
import FallbackVisitor from '../../FallbackVisitor';
import SpecificationVisitor from '../../SpecificationVisitor';
import FixedFieldsVisitor from '../../generics/FixedFieldsVisitor';

const SchemaVisitor = stampit(SpecificationVisitor, FallbackVisitor, {
methods: {
ObjectElement(objectElement: ObjectElement) {
// @ts-ignore
const schemaElement = new SchemaElement(objectElement.content);

this.copyMetaAndAttributes(objectElement, schemaElement);

this.element = schemaElement;
return BREAK;
},
const SchemaVisitor = stampit(FixedFieldsVisitor, FallbackVisitor, {
props: {
specPath: always(['document', 'objects', 'Schema']),
canSupportSpecificationExtensions: true,
},
init() {
this.element = new SchemaElement();
},
});

Expand Down

0 comments on commit e9e0cd0

Please sign in to comment.