openapi-sync 1.0.20 → 1.0.21

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.
@@ -127,6 +127,21 @@ const parseSchemaToType = (apiDoc, schema, name, isRequired, options) => {
127
127
  //TODO $ref is a uri - use axios to fetch doc
128
128
  }
129
129
  }
130
+ else if (schema.anyOf) {
131
+ type += `(${schema.anyOf
132
+ .map((v) => (0, exports.parseSchemaToType)(apiDoc, v, "", isRequired, options))
133
+ .join("|")})`;
134
+ }
135
+ else if (schema.oneOf) {
136
+ type += `(${schema.oneOf
137
+ .map((v) => (0, exports.parseSchemaToType)(apiDoc, v, "", isRequired, options))
138
+ .join("|")})`;
139
+ }
140
+ else if (schema.allOf) {
141
+ type += `(${schema.allOf
142
+ .map((v) => (0, exports.parseSchemaToType)(apiDoc, v, "", isRequired, options))
143
+ .join("&")})`;
144
+ }
130
145
  else if (schema.type) {
131
146
  if (schema.enum && schema.enum.length > 0) {
132
147
  if (schema.enum.length > 1)
@@ -138,11 +153,8 @@ const parseSchemaToType = (apiDoc, schema, name, isRequired, options) => {
138
153
  if (schema.enum.length > 1)
139
154
  type += ")";
140
155
  }
141
- else if (["string", "integer", "number", "array"].includes(schema.type)) {
142
- if (schema.type === "string") {
143
- type += `string`;
144
- }
145
- else if (["integer", "number"].includes(schema.type)) {
156
+ else if (["string", "integer", "number", "array", "boolean"].includes(schema.type)) {
157
+ if (["integer", "number"].includes(schema.type)) {
146
158
  type += `number`;
147
159
  }
148
160
  else if (schema.type === "array") {
@@ -153,6 +165,9 @@ const parseSchemaToType = (apiDoc, schema, name, isRequired, options) => {
153
165
  type += "any[]";
154
166
  }
155
167
  }
168
+ else {
169
+ type += schema.type;
170
+ }
156
171
  }
157
172
  else if (schema.type === "object") {
158
173
  if (schema.properties) {
@@ -171,9 +186,19 @@ const parseSchemaToType = (apiDoc, schema, name, isRequired, options) => {
171
186
  type += "object";
172
187
  }
173
188
  }
189
+ else {
190
+ type += "object";
191
+ }
174
192
  }
175
193
  }
176
194
  }
177
- return type.length > 0 ? `${typeName}${type}${name ? ";\n" : ""}` : "";
195
+ else {
196
+ //Default type to string if no schema provided
197
+ type = "string";
198
+ }
199
+ const nullable = (schema === null || schema === void 0 ? void 0 : schema.nullable) ? " | null" : "";
200
+ return type.length > 0
201
+ ? `${typeName}${type}${nullable}${name ? ";\n" : ""}`
202
+ : "";
178
203
  };
179
204
  exports.parseSchemaToType = parseSchemaToType;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openapi-sync",
3
- "version": "1.0.20",
3
+ "version": "1.0.21",
4
4
  "description": "A developer-friendly tool designed to keep your API up-to-date by leveraging OpenAPI schemas. It automates the generation of endpoint URIs and type definitions, including shared types, directly from your OpenAPI specification.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",