@scalar/oas-utils 0.2.100 → 0.2.101

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @scalar/oas-utils
2
2
 
3
+ ## 0.2.101
4
+
5
+ ### Patch Changes
6
+
7
+ - be34e7d: feat: adds value to server variables schema
8
+ - Updated dependencies [be34e7d]
9
+ - Updated dependencies [51f3177]
10
+ - @scalar/types@0.0.29
11
+ - @scalar/themes@0.9.63
12
+
3
13
  ## 0.2.100
4
14
 
5
15
  ### Patch Changes
@@ -1,4 +1,5 @@
1
- import { z } from 'zod';
1
+ import type { OpenAPIV3_1 } from '@scalar/openapi-types';
2
+ import { type ZodSchema, z } from 'zod';
2
3
  /**
3
4
  * Server Variable Object
4
5
  *
@@ -6,15 +7,15 @@ import { z } from 'zod';
6
7
  *
7
8
  * @see https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#server-variable-object
8
9
  */
9
- export declare const oasServerVariableSchema: z.ZodEffects<z.ZodObject<{
10
+ export declare const oasServerVariableSchema: z.ZodObject<{
10
11
  /**
11
12
  * An enumeration of string values to be used if the substitution options are from a limited set. The array MUST NOT be empty.
12
13
  */
13
14
  enum: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
14
15
  /**
15
16
  * REQUIRED. The default value to use for substitution, which SHALL be sent if an alternate value is not supplied.
16
- * Note this behavior is different than the Schema Objects treatment of default values, because in those cases
17
- * parameter values are optional. If the enum is defined, the value MUST exist in the enums values.
17
+ * Note this behavior is different than the Schema Object's treatment of default values, because in those cases
18
+ * parameter values are optional. If the enum is defined, the value MUST exist in the enum's values.
18
19
  */
19
20
  default: z.ZodOptional<z.ZodString>;
20
21
  /**
@@ -29,14 +30,6 @@ export declare const oasServerVariableSchema: z.ZodEffects<z.ZodObject<{
29
30
  default?: string | undefined;
30
31
  description?: string | undefined;
31
32
  enum?: string[] | undefined;
32
- }>, {
33
- default?: string | undefined;
34
- description?: string | undefined;
35
- enum?: string[] | undefined;
36
- }, {
37
- default?: string | undefined;
38
- description?: string | undefined;
39
- enum?: string[] | undefined;
40
33
  }>;
41
34
  /**
42
35
  * Server Object
@@ -58,53 +51,26 @@ export declare const oasServerSchema: z.ZodObject<{
58
51
  */
59
52
  description: z.ZodOptional<z.ZodString>;
60
53
  /** A map between a variable name and its value. The value is used for substitution in the server's URL template. */
61
- variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodObject<{
62
- /**
63
- * An enumeration of string values to be used if the substitution options are from a limited set. The array MUST NOT be empty.
64
- */
65
- enum: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
66
- /**
67
- * REQUIRED. The default value to use for substitution, which SHALL be sent if an alternate value is not supplied.
68
- * Note this behavior is different than the Schema Object’s treatment of default values, because in those cases
69
- * parameter values are optional. If the enum is defined, the value MUST exist in the enum’s values.
70
- */
71
- default: z.ZodOptional<z.ZodString>;
72
- /**
73
- * An optional description for the server variable. CommonMark syntax MAY be used for rich text representation.
74
- */
75
- description: z.ZodOptional<z.ZodString>;
76
- }, "strip", z.ZodTypeAny, {
77
- default?: string | undefined;
78
- description?: string | undefined;
79
- enum?: string[] | undefined;
80
- }, {
81
- default?: string | undefined;
82
- description?: string | undefined;
83
- enum?: string[] | undefined;
84
- }>, {
85
- default?: string | undefined;
86
- description?: string | undefined;
87
- enum?: string[] | undefined;
88
- }, {
89
- default?: string | undefined;
90
- description?: string | undefined;
91
- enum?: string[] | undefined;
54
+ variables: z.ZodOptional<z.ZodRecord<z.ZodString, ZodSchema<Omit<OpenAPIV3_1.ServerVariableObject, "enum"> & {
55
+ enum?: [string, ...string[]];
56
+ value?: string;
57
+ }, z.ZodTypeDef, Omit<OpenAPIV3_1.ServerVariableObject, "enum"> & {
58
+ enum?: [string, ...string[]];
59
+ value?: string;
92
60
  }>>>;
93
61
  }, "strip", z.ZodTypeAny, {
94
62
  url: string;
95
63
  description?: string | undefined;
96
- variables?: Record<string, {
97
- default?: string | undefined;
98
- description?: string | undefined;
99
- enum?: string[] | undefined;
64
+ variables?: Record<string, Omit<OpenAPIV3_1.ServerVariableObject, "enum"> & {
65
+ enum?: [string, ...string[]];
66
+ value?: string;
100
67
  }> | undefined;
101
68
  }, {
102
69
  url: string;
103
70
  description?: string | undefined;
104
- variables?: Record<string, {
105
- default?: string | undefined;
106
- description?: string | undefined;
107
- enum?: string[] | undefined;
71
+ variables?: Record<string, Omit<OpenAPIV3_1.ServerVariableObject, "enum"> & {
72
+ enum?: [string, ...string[]];
73
+ value?: string;
108
74
  }> | undefined;
109
75
  }>;
110
76
  export declare const serverSchema: z.ZodObject<z.objectUtil.extendShape<{
@@ -120,37 +86,12 @@ export declare const serverSchema: z.ZodObject<z.objectUtil.extendShape<{
120
86
  */
121
87
  description: z.ZodOptional<z.ZodString>;
122
88
  /** A map between a variable name and its value. The value is used for substitution in the server's URL template. */
123
- variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodObject<{
124
- /**
125
- * An enumeration of string values to be used if the substitution options are from a limited set. The array MUST NOT be empty.
126
- */
127
- enum: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
128
- /**
129
- * REQUIRED. The default value to use for substitution, which SHALL be sent if an alternate value is not supplied.
130
- * Note this behavior is different than the Schema Object’s treatment of default values, because in those cases
131
- * parameter values are optional. If the enum is defined, the value MUST exist in the enum’s values.
132
- */
133
- default: z.ZodOptional<z.ZodString>;
134
- /**
135
- * An optional description for the server variable. CommonMark syntax MAY be used for rich text representation.
136
- */
137
- description: z.ZodOptional<z.ZodString>;
138
- }, "strip", z.ZodTypeAny, {
139
- default?: string | undefined;
140
- description?: string | undefined;
141
- enum?: string[] | undefined;
142
- }, {
143
- default?: string | undefined;
144
- description?: string | undefined;
145
- enum?: string[] | undefined;
146
- }>, {
147
- default?: string | undefined;
148
- description?: string | undefined;
149
- enum?: string[] | undefined;
150
- }, {
151
- default?: string | undefined;
152
- description?: string | undefined;
153
- enum?: string[] | undefined;
89
+ variables: z.ZodOptional<z.ZodRecord<z.ZodString, ZodSchema<Omit<OpenAPIV3_1.ServerVariableObject, "enum"> & {
90
+ enum?: [string, ...string[]];
91
+ value?: string;
92
+ }, z.ZodTypeDef, Omit<OpenAPIV3_1.ServerVariableObject, "enum"> & {
93
+ enum?: [string, ...string[]];
94
+ value?: string;
154
95
  }>>>;
155
96
  }, {
156
97
  uid: z.ZodDefault<z.ZodOptional<z.ZodString>>;
@@ -158,19 +99,17 @@ export declare const serverSchema: z.ZodObject<z.objectUtil.extendShape<{
158
99
  uid: string;
159
100
  url: string;
160
101
  description?: string | undefined;
161
- variables?: Record<string, {
162
- default?: string | undefined;
163
- description?: string | undefined;
164
- enum?: string[] | undefined;
102
+ variables?: Record<string, Omit<OpenAPIV3_1.ServerVariableObject, "enum"> & {
103
+ enum?: [string, ...string[]];
104
+ value?: string;
165
105
  }> | undefined;
166
106
  }, {
167
107
  url: string;
168
108
  uid?: string | undefined;
169
109
  description?: string | undefined;
170
- variables?: Record<string, {
171
- default?: string | undefined;
172
- description?: string | undefined;
173
- enum?: string[] | undefined;
110
+ variables?: Record<string, Omit<OpenAPIV3_1.ServerVariableObject, "enum"> & {
111
+ enum?: [string, ...string[]];
112
+ value?: string;
174
113
  }> | undefined;
175
114
  }>;
176
115
  export type Server = z.infer<typeof serverSchema>;
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/entities/spec/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB;IAEhC;;OAEG;;IAEH;;;;OAIG;;IAEH;;OAEG;;;;;;;;;;;;;;;;;;EAmBH,CAAA;AAEJ;;;;;;GAMG;AACH,eAAO,MAAM,eAAe;IAC1B;;;;OAIG;;IAEH;;;OAGG;;IAEH,oHAAoH;;QApDlH;;WAEG;;QAEH;;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AAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;gBACpB,MAAM;;;;;;;;;eADP,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;gBACpB,MAAM;;;;;;;eADP,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;gBACpB,MAAM;;EA6BhB,CAAA;AAEF,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA;AACjD,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA"}
@@ -8,22 +8,27 @@ import { nanoidSchema } from '../shared/utility.js';
8
8
  *
9
9
  * @see https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#server-variable-object
10
10
  */
11
- const oasServerVariableSchema = z
12
- .object({
11
+ const oasServerVariableSchema = z.object({
13
12
  /**
14
13
  * An enumeration of string values to be used if the substitution options are from a limited set. The array MUST NOT be empty.
15
14
  */
16
15
  enum: z.array(z.string()).optional(),
17
16
  /**
18
17
  * REQUIRED. The default value to use for substitution, which SHALL be sent if an alternate value is not supplied.
19
- * Note this behavior is different than the Schema Objects treatment of default values, because in those cases
20
- * parameter values are optional. If the enum is defined, the value MUST exist in the enums values.
18
+ * Note this behavior is different than the Schema Object's treatment of default values, because in those cases
19
+ * parameter values are optional. If the enum is defined, the value MUST exist in the enum's values.
21
20
  */
22
21
  default: z.string().optional(),
23
22
  /**
24
23
  * An optional description for the server variable. CommonMark syntax MAY be used for rich text representation.
25
24
  */
26
25
  description: z.string().optional(),
26
+ });
27
+ /** Extended schema for server variables */
28
+ const extendedServerVariableSchema = oasServerVariableSchema
29
+ .extend({
30
+ /** The value of the variable */
31
+ value: z.string().optional(),
27
32
  })
28
33
  .refine((data) => {
29
34
  // Set default to the first enum value if invalid
@@ -58,7 +63,7 @@ const oasServerSchema = z.object({
58
63
  */
59
64
  description: z.string().optional(),
60
65
  /** A map between a variable name and its value. The value is used for substitution in the server's URL template. */
61
- variables: z.record(z.string(), oasServerVariableSchema).optional(),
66
+ variables: z.record(z.string(), extendedServerVariableSchema).optional(),
62
67
  });
63
68
  const serverSchema = oasServerSchema.extend({
64
69
  uid: nanoidSchema,
@@ -256,7 +256,7 @@ async function importSpecToWorkspace(spec, { authentication, baseServerURL, docu
256
256
  });
257
257
  // Add the request UIDs to the tag children (or collection root)
258
258
  requests.forEach((r) => {
259
- if (r.tags) {
259
+ if (r.tags?.length) {
260
260
  r.tags.forEach((t) => {
261
261
  tagMap[t].children.push(r.uid);
262
262
  });
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "specification",
17
17
  "yaml"
18
18
  ],
19
- "version": "0.2.100",
19
+ "version": "0.2.101",
20
20
  "engines": {
21
21
  "node": ">=18"
22
22
  },
@@ -122,17 +122,17 @@
122
122
  "yaml": "^2.4.5",
123
123
  "zod": "^3.23.8",
124
124
  "@scalar/object-utils": "1.1.12",
125
- "@scalar/themes": "0.9.62",
126
- "@scalar/types": "0.0.28",
127
- "@scalar/openapi-types": "0.1.6"
125
+ "@scalar/openapi-types": "0.1.6",
126
+ "@scalar/themes": "0.9.63",
127
+ "@scalar/types": "0.0.29"
128
128
  },
129
129
  "devDependencies": {
130
130
  "type-fest": "^4.20.0",
131
131
  "vite": "^5.4.10",
132
132
  "vitest": "^1.6.0",
133
133
  "zod-to-ts": "github:amritk/zod-to-ts#build",
134
- "@scalar/build-tooling": "0.1.12",
135
134
  "@scalar/openapi-parser": "0.10.4",
135
+ "@scalar/build-tooling": "0.1.12",
136
136
  "@scalar/openapi-types": "0.1.6"
137
137
  },
138
138
  "scripts": {