svelte-reflector 1.0.27 → 1.0.28

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.
@@ -6,6 +6,7 @@ export declare class ObjectProp {
6
6
  constructor(params: {
7
7
  referenceObject: ReferenceObject;
8
8
  name: string;
9
+ isRequired?: boolean;
9
10
  });
10
11
  constructorBuild(): string;
11
12
  classBuild(): string;
@@ -3,10 +3,10 @@ export class ObjectProp {
3
3
  type;
4
4
  required;
5
5
  constructor(params) {
6
- const { referenceObject, name } = params;
6
+ const { referenceObject, name, isRequired } = params;
7
7
  this.name = name;
8
8
  this.type = referenceObject.$ref.split("/").at(-1) ?? "";
9
- this.required = true; // tem que ver isso daí
9
+ this.required = isRequired ?? true; // tem que ver isso daí
10
10
  }
11
11
  constructorBuild() {
12
12
  return `this.${this.name} = new ${this.type}(params?.${this.name})`;
@@ -10,7 +10,8 @@ export class PrimitiveProp {
10
10
  const { example: rawExample, type: rawType } = schemaObject;
11
11
  const type = rawType ?? "string";
12
12
  const example = rawExample ?? this.getEmptyExample({ type, schemaObject });
13
- const buildedType = required ? type : `${type} | undefined`;
13
+ // const buildedType = required ? type : `${type} | undefined`;
14
+ const buildedType = type;
14
15
  this.name = this.treatName(name);
15
16
  this.rawType = type ?? "any";
16
17
  this.type = `BuildedInput<${buildedType}>`;
package/dist/schema.js CHANGED
@@ -17,7 +17,14 @@ export class Schema {
17
17
  this.name = `${isEmpty ? "Empty" : ""}${name}`;
18
18
  for (const [key, value] of Object.entries(properties)) {
19
19
  if ("$ref" in value || !value?.type) {
20
- if ("$ref" in value) {
20
+ if ("allOf" in value) {
21
+ const ref = value.allOf?.[0];
22
+ const isRequired = !!value.nullable;
23
+ if (ref && "$ref" in ref) {
24
+ this.objectProps.push(new ObjectProp({ name: key, referenceObject: ref, isRequired }));
25
+ }
26
+ }
27
+ else if ("$ref" in value) {
21
28
  this.objectProps.push(new ObjectProp({ name: key, referenceObject: value }));
22
29
  }
23
30
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-reflector",
3
- "version": "1.0.27",
3
+ "version": "1.0.28",
4
4
  "description": "Reflects zod types from openAPI schemas",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",