@goast/core 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,16 +14,22 @@ class DerefProxyHandler {
14
14
  this._overwrittenValues = {};
15
15
  }
16
16
  get(target, prop) {
17
- var _a, _b, _c;
17
+ var _a;
18
18
  if (prop === '$ref') {
19
19
  return this._ref;
20
20
  }
21
21
  else if (prop === '$src') {
22
22
  return this._source;
23
23
  }
24
- return ((_b = (_a = this._overwrittenValues[prop]) !== null && _a !== void 0 ? _a : target[prop]) !== null && _b !== void 0 ? _b : (propertiesNotDerivedFromRef.includes(prop)
24
+ if (this._overwrittenValues[prop] !== undefined) {
25
+ return this._overwrittenValues[prop];
26
+ }
27
+ if (target[prop] !== undefined) {
28
+ return target[prop];
29
+ }
30
+ return propertiesNotDerivedFromRef.includes(prop)
25
31
  ? undefined
26
- : (_c = this._ref) === null || _c === void 0 ? void 0 : _c[prop]));
32
+ : (_a = this._ref) === null || _a === void 0 ? void 0 : _a[prop];
27
33
  }
28
34
  set(target, prop, value) {
29
35
  if (prop === '$ref' && (typeof value === 'object' || typeof value === 'undefined')) {
@@ -17,14 +17,14 @@ function transformSchema(context, schema) {
17
17
  if (existing)
18
18
  return existing;
19
19
  let kind = (0, helpers_1.determineSchemaKind)(schema);
20
- let nullable = false;
20
+ let nullable = kind === 'null';
21
21
  if (kind === 'multi-type') {
22
22
  const types = schema.type;
23
23
  let isSingleType = types.length === 1;
24
24
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
25
- if (types.length === 2 && (types.includes('null') || types.includes(null))) {
25
+ if (types.includes('null') || types.includes(null)) {
26
26
  nullable = true;
27
- isSingleType = true;
27
+ isSingleType = types.length === 2;
28
28
  }
29
29
  if (isSingleType) {
30
30
  const newType = types.filter((t) => t !== 'null' && t !== null)[0];
@@ -32,6 +32,9 @@ function transformSchema(context, schema) {
32
32
  schema.type = newType;
33
33
  kind = (0, helpers_1.determineSchemaKind)(schema);
34
34
  }
35
+ else {
36
+ schema.type = types.filter((t) => t !== 'null' && t !== null);
37
+ }
35
38
  }
36
39
  const id = context.idGenerator.generateId('schema');
37
40
  const nameInfo = (0, helpers_1.determineSchemaName)(schema, id);
@@ -10,16 +10,22 @@ class DerefProxyHandler {
10
10
  this._overwrittenValues = {};
11
11
  }
12
12
  get(target, prop) {
13
- var _a, _b, _c;
13
+ var _a;
14
14
  if (prop === '$ref') {
15
15
  return this._ref;
16
16
  }
17
17
  else if (prop === '$src') {
18
18
  return this._source;
19
19
  }
20
- return ((_b = (_a = this._overwrittenValues[prop]) !== null && _a !== void 0 ? _a : target[prop]) !== null && _b !== void 0 ? _b : (propertiesNotDerivedFromRef.includes(prop)
20
+ if (this._overwrittenValues[prop] !== undefined) {
21
+ return this._overwrittenValues[prop];
22
+ }
23
+ if (target[prop] !== undefined) {
24
+ return target[prop];
25
+ }
26
+ return propertiesNotDerivedFromRef.includes(prop)
21
27
  ? undefined
22
- : (_c = this._ref) === null || _c === void 0 ? void 0 : _c[prop]));
28
+ : (_a = this._ref) === null || _a === void 0 ? void 0 : _a[prop];
23
29
  }
24
30
  set(target, prop, value) {
25
31
  if (prop === '$ref' && (typeof value === 'object' || typeof value === 'undefined')) {
@@ -14,14 +14,14 @@ export function transformSchema(context, schema) {
14
14
  if (existing)
15
15
  return existing;
16
16
  let kind = determineSchemaKind(schema);
17
- let nullable = false;
17
+ let nullable = kind === 'null';
18
18
  if (kind === 'multi-type') {
19
19
  const types = schema.type;
20
20
  let isSingleType = types.length === 1;
21
21
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
22
- if (types.length === 2 && (types.includes('null') || types.includes(null))) {
22
+ if (types.includes('null') || types.includes(null)) {
23
23
  nullable = true;
24
- isSingleType = true;
24
+ isSingleType = types.length === 2;
25
25
  }
26
26
  if (isSingleType) {
27
27
  const newType = types.filter((t) => t !== 'null' && t !== null)[0];
@@ -29,6 +29,9 @@ export function transformSchema(context, schema) {
29
29
  schema.type = newType;
30
30
  kind = determineSchemaKind(schema);
31
31
  }
32
+ else {
33
+ schema.type = types.filter((t) => t !== 'null' && t !== null);
34
+ }
32
35
  }
33
36
  const id = context.idGenerator.generateId('schema');
34
37
  const nameInfo = determineSchemaName(schema, id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goast/core",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "repository": "https://github.com/MaSch0212/goast.git",
5
5
  "author": {
6
6
  "name": "Marc Schmidt (MaSch0212)",