osury 0.27.0 → 0.29.0

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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "osury",
3
3
  "type": "module",
4
4
  "description": "Generate ReScript types with Sury schemas from OpenAPI specifications",
5
- "version": "0.27.0",
5
+ "version": "0.29.0",
6
6
  "license": "MIT",
7
7
  "bin": {
8
8
  "osury": "bin/osury.mjs"
@@ -32,7 +32,7 @@ function printPrimitive(p) {
32
32
 
33
33
  function printType(t) {
34
34
  if (typeof t !== "object") {
35
- return "JSON.t";
35
+ return "@s.matches(S.json) JSON.t";
36
36
  }
37
37
  switch (t.TAG) {
38
38
  case "Primitive" :
@@ -348,7 +348,23 @@ function topologicalSort(schemas) {
348
348
  function buildSkipSchemaSet(schemas) {
349
349
  let skipSet = {};
350
350
  schemas.forEach(s => {
351
- if (CodegenHelpers.hasUnion(s.schema) || CodegenHelpers.hasUnknown(s.schema)) {
351
+ let types = s.schema;
352
+ let hasInlineProblem;
353
+ if (typeof types !== "object") {
354
+ hasInlineProblem = CodegenHelpers.hasUnion(s.schema);
355
+ } else {
356
+ switch (types._tag) {
357
+ case "PolyVariant" :
358
+ hasInlineProblem = types._0.some(c => CodegenHelpers.hasUnion(c.payload));
359
+ break;
360
+ case "Union" :
361
+ hasInlineProblem = types._0.some(CodegenHelpers.hasUnion);
362
+ break;
363
+ default:
364
+ hasInlineProblem = CodegenHelpers.hasUnion(s.schema);
365
+ }
366
+ }
367
+ if (hasInlineProblem) {
352
368
  skipSet[s.name] = true;
353
369
  return;
354
370
  }
package/src/IRGen.res.mjs CHANGED
@@ -166,16 +166,17 @@ function convertToIrTypeDef(namedSchema, schemasDict, tagsDict, skipSchemaSet) {
166
166
  payload: payload
167
167
  };
168
168
  });
169
+ let baseAnnotations = [
170
+ "GenType",
171
+ {
172
+ TAG: "Tag",
173
+ _0: tagName
174
+ }
175
+ ];
176
+ let annotations = shouldSkipSchema ? baseAnnotations : baseAnnotations.concat(["Schema"]);
169
177
  return {
170
178
  name: typeName,
171
- annotations: [
172
- "GenType",
173
- {
174
- TAG: "Tag",
175
- _0: tagName
176
- },
177
- "Schema"
178
- ],
179
+ annotations: annotations,
179
180
  kind: {
180
181
  TAG: "VariantDef",
181
182
  _0: irCases
@@ -192,17 +193,18 @@ function convertToIrTypeDef(namedSchema, schemasDict, tagsDict, skipSchemaSet) {
192
193
  payload: payload
193
194
  };
194
195
  });
196
+ let baseAnnotations$1 = [
197
+ "GenType",
198
+ {
199
+ TAG: "Tag",
200
+ _0: tagName
201
+ },
202
+ "Unboxed"
203
+ ];
204
+ let annotations$1 = shouldSkipSchema ? baseAnnotations$1 : baseAnnotations$1.concat(["Schema"]);
195
205
  return {
196
206
  name: typeName,
197
- annotations: [
198
- "GenType",
199
- {
200
- TAG: "Tag",
201
- _0: tagName
202
- },
203
- "Unboxed",
204
- "Schema"
205
- ],
207
+ annotations: annotations$1,
206
208
  kind: {
207
209
  TAG: "VariantDef",
208
210
  _0: irCases$1
@@ -244,16 +246,17 @@ function convertToIrTypeDef(namedSchema, schemasDict, tagsDict, skipSchemaSet) {
244
246
  payload: payload$1
245
247
  };
246
248
  });
249
+ let baseAnnotations$2 = [
250
+ "GenType",
251
+ {
252
+ TAG: "Tag",
253
+ _0: tagName
254
+ }
255
+ ];
256
+ let annotations$2 = shouldSkipSchema ? baseAnnotations$2 : baseAnnotations$2.concat(["Schema"]);
247
257
  return {
248
258
  name: typeName,
249
- annotations: [
250
- "GenType",
251
- {
252
- TAG: "Tag",
253
- _0: tagName
254
- },
255
- "Schema"
256
- ],
259
+ annotations: annotations$2,
257
260
  kind: {
258
261
  TAG: "VariantDef",
259
262
  _0: irCases$2
@@ -278,13 +281,13 @@ function convertToIrTypeDef(namedSchema, schemasDict, tagsDict, skipSchemaSet) {
278
281
  _0: convertType(namedSchema.schema)
279
282
  });
280
283
  }
281
- let annotations = shouldSkipSchema ? ["GenType"] : [
284
+ let annotations$3 = shouldSkipSchema ? ["GenType"] : [
282
285
  "GenType",
283
286
  "Schema"
284
287
  ];
285
288
  return {
286
289
  name: typeName,
287
- annotations: annotations,
290
+ annotations: annotations$3,
288
291
  kind: kind
289
292
  };
290
293
  }