Skip to content

Commit

Permalink
feat(workflows-1): use JSON Schema 2020-12 namespace
Browse files Browse the repository at this point in the history
Refs #1822
  • Loading branch information
char0n committed Jan 26, 2025
1 parent a69a698 commit e843473
Show file tree
Hide file tree
Showing 15 changed files with 60 additions and 185 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/apidom-ns-workflows-1/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"dependencies": {
"@babel/runtime-corejs3": "^7.20.7",
"@swagger-api/apidom-core": "^1.0.0-beta.10",
"@swagger-api/apidom-ns-openapi-3-1": "^1.0.0-beta.10",
"@swagger-api/apidom-ns-json-schema-2020-12": "^1.0.0-beta.10",
"@types/ramda": "~0.30.0",
"ramda": "~0.30.0",
"ramda-adjunct": "^5.0.0",
Expand Down
50 changes: 0 additions & 50 deletions packages/apidom-ns-workflows-1/src/elements/JSONSchema.ts

This file was deleted.

3 changes: 1 addition & 2 deletions packages/apidom-ns-workflows-1/src/elements/Workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import {
Attributes,
Meta,
} from '@swagger-api/apidom-core';

import JSONSchemaElement from './JSONSchema.ts';
import { JSONSchemaElement } from '@swagger-api/apidom-ns-json-schema-2020-12';

/**
* @public
Expand Down
4 changes: 2 additions & 2 deletions packages/apidom-ns-workflows-1/src/namespace.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { NamespacePluginOptions } from '@swagger-api/apidom-core';
import { JSONSchemaElement } from '@swagger-api/apidom-ns-json-schema-2020-12';

import WorkflowsSpecification1Element from './elements/WorkflowsSpecification1.ts';
import WorkflowsSpecElement from './elements/WorkflowsSpec.ts';
Expand All @@ -12,7 +13,6 @@ import FailureActionElement from './elements/FailureAction.ts';
import ComponentsElement from './elements/Components.ts';
import CriterionElement from './elements/Criterion.ts';
import ReferenceElement from './elements/Reference.ts';
import JSONSchemaElement from './elements/JSONSchema.ts';

/**
* @public
Expand All @@ -33,7 +33,7 @@ const workflows1 = {
base.register('components', ComponentsElement);
base.register('criterion', CriterionElement);
base.register('reference', ReferenceElement);
base.register('jSONSchemaDraft202012', JSONSchemaElement);
base.register('jSONSchema202012', JSONSchemaElement);

return base;
},
Expand Down
17 changes: 3 additions & 14 deletions packages/apidom-ns-workflows-1/src/predicates.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createPredicate } from '@swagger-api/apidom-core';
import { isJSONSchemaElement } from '@swagger-api/apidom-ns-json-schema-2020-12';

import WorkflowsSpecification1Element from './elements/WorkflowsSpecification1.ts';
import WorkflowsSpecElement from './elements/WorkflowsSpec.ts';
Expand All @@ -12,7 +13,6 @@ import FailureActionElement from './elements/FailureAction.ts';
import ComponentsElement from './elements/Components.ts';
import CriterionElement from './elements/Criterion.ts';
import ReferenceElement from './elements/Reference.ts';
import JSONSchemaElement from './elements/JSONSchema.ts';
// NCE types
import WorkflowsElement from './elements/nces/Workflows.ts';
import SourceDescriptionsElement from './elements/nces/SourceDescriptions.ts';
Expand All @@ -27,6 +27,8 @@ import StepOutputsElement from './elements/nces/StepOutputs.ts';
import SuccessActionCriteriaElement from './elements/nces/SuccessActionCriteria.ts';
import FailureActionCriteriaElement from './elements/nces/FailureActionCriteria.ts';

export { isJSONSchemaElement };

/**
* @public
*/
Expand Down Expand Up @@ -356,16 +358,3 @@ export const isFailureActionCriteriaElement = createPredicate(
hasClass('criteria', element));
},
);

/**
* @public
*/
export const isJSONSchemaElement = createPredicate(
({ hasBasicElementProps, isElementType, primitiveEq }) => {
return (element: unknown): element is JSONSchemaElement =>
element instanceof JSONSchemaElement ||
(hasBasicElementProps(element) &&
isElementType('jSONSchemaDraft202012', element) &&
primitiveEq('object', element));
},
);
3 changes: 2 additions & 1 deletion packages/apidom-ns-workflows-1/src/refractor/registration.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { JSONSchemaElement } from '@swagger-api/apidom-ns-json-schema-2020-12';

import WorkflowsSpecification1Element from '../elements/WorkflowsSpecification1.ts';
import WorkflowsSpecElement from '../elements/WorkflowsSpec.ts';
import InfoElement from '../elements/Info.ts';
Expand All @@ -10,7 +12,6 @@ import FailureActionElement from '../elements/FailureAction.ts';
import ComponentsElement from '../elements/Components.ts';
import CriterionElement from '../elements/Criterion.ts';
import ReferenceElement from '../elements/Reference.ts';
import JSONSchemaElement from '../elements/JSONSchema.ts';
import { createRefractor } from './index.ts';

InfoElement.refract = createRefractor(['visitors', 'document', 'objects', 'Info', '$visitor']);
Expand Down
24 changes: 3 additions & 21 deletions packages/apidom-ns-workflows-1/src/refractor/specification.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { omit } from 'ramda';
import { specificationObj as OpenApi3_1Specification } from '@swagger-api/apidom-ns-openapi-3-1';
import { specificationObj as jsonSchemaSpecificationObj } from '@swagger-api/apidom-ns-json-schema-2020-12';

import WorkflowsSpecificationVisitor from './visitors/workflows-1/index.ts';
import WorkflowsSpecVisitor from './visitors/workflows-1/WorkflowsSpecVisitor.ts';
Expand Down Expand Up @@ -30,7 +29,6 @@ import ComponentsParametersVisitor from './visitors/workflows-1/components/Param
import CriterionVisitor from './visitors/workflows-1/criterion/index.ts';
import ReferenceVisitor from './visitors/workflows-1/reference/index.ts';
import Reference$RefVisitor from './visitors/workflows-1/reference/$RefVisitor.ts';
import JSONSchemaVisitor from './visitors/workflows-1/json-schema/index.ts';
import SpecificationExtensionVisitor from './visitors/SpecificationExtensionVisitor.ts';
import FallbackVisitor from './visitors/FallbackVisitor.ts';

Expand All @@ -43,11 +41,7 @@ import FallbackVisitor from './visitors/FallbackVisitor.ts';
* Note: Specification object allows to use absolute internal JSON pointers.
*/

const { fixedFields: schemaFixedFields } = OpenApi3_1Specification.visitors.document.objects.Schema;
const jsonSchemaFixedFields = omit(
['discriminator', 'xml', 'externalDocs', 'example'],
schemaFixedFields,
); // getting rid of OAS base dialect keywords
const { JSONSchema: JSONSchemaVisitor } = jsonSchemaSpecificationObj.visitors.document.objects;

/**
* @public
Expand Down Expand Up @@ -167,19 +161,7 @@ const specification = {
value: { $ref: '#/visitors/value' },
},
},
Schema: {
/**
* Internally the fixed field visitors are using references to `/document/objects/Schema`.
* Schema spec make sure it's pointing to our JSONSchema visitor and basically acts like
* an alias for it.
*/
$visitor: JSONSchemaVisitor,
fixedFields: jsonSchemaFixedFields,
},
JSONSchema: {
$visitor: JSONSchemaVisitor,
fixedFields: jsonSchemaFixedFields,
},
JSONSchema: JSONSchemaVisitor,
},
extension: {
$visitor: SpecificationExtensionVisitor,
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion packages/apidom-ns-workflows-1/src/traversal/visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ export const keyMap = {
ComponentsElement: ['content'],
CriterionElement: ['content'],
ReferenceElement: ['content'],
JSONSchemaDraft202012Element: ['content'],
JSONSchema202012Element: ['content'],
...keyMapBase,
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ exports[`refractor elements ComponentsElement should refract to semantic ApiDOM
(ObjectElement
(MemberElement
(StringElement)
(JSONSchemaDraft202012Element))))
(JSONSchema202012Element))))
(MemberElement
(StringElement)
(ObjectElement
Expand Down
Loading

0 comments on commit e843473

Please sign in to comment.