source: node_modules/@swagger-api/apidom-ast/es/yaml/schemas/json/index.mjs@ d24f17c

main
Last change on this file since d24f17c was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 1.4 KB
Line 
1import FailsafeSchema from "../failsafe/index.mjs";
2import BooleanTag from "./Boolean.mjs";
3import FloatingPointTag from "./FloatingPoint.mjs";
4import IntegerTag from "./Integer.mjs";
5import NullTag from "./Null.mjs";
6import { YamlNodeKind } from "../../nodes/YamlTag.mjs";
7import GenericSequence from "../failsafe/GenericSequence.mjs";
8import GenericMapping from "../failsafe/GenericMapping.mjs";
9class JsonSchema extends FailsafeSchema {
10 constructor() {
11 super();
12 /**
13 * We're registering more specific tags before more generic ones from Failsafe schema.
14 */
15 this.registerTag(new BooleanTag(), true);
16 this.registerTag(new FloatingPointTag(), true);
17 this.registerTag(new IntegerTag(), true);
18 this.registerTag(new NullTag(), true);
19 }
20 toSpecificTagName(node) {
21 let specificTagName = super.toSpecificTagName(node);
22 if (specificTagName === '?') {
23 if (node.tag.vkind === YamlNodeKind.Sequence) {
24 specificTagName = GenericSequence.uri;
25 } else if (node.tag.kind === YamlNodeKind.Mapping) {
26 specificTagName = GenericMapping.uri;
27 } else if (node.tag.kind === YamlNodeKind.Scalar) {
28 const foundTag = this.tags.find(tag => tag.test(node));
29 specificTagName = (foundTag === null || foundTag === void 0 ? void 0 : foundTag.tag) || '?';
30 }
31 }
32 return specificTagName;
33 }
34}
35export default JsonSchema;
Note: See TracBrowser for help on using the repository browser.