osury 0.25.0 → 0.26.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/IRGen.res.mjs +22 -9
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.25.0",
5
+ "version": "0.26.0",
6
6
  "license": "MIT",
7
7
  "bin": {
8
8
  "osury": "bin/osury.mjs"
package/src/IRGen.res.mjs CHANGED
@@ -48,10 +48,15 @@ function convertType(schema) {
48
48
  _0: convertType(schema._0)
49
49
  };
50
50
  case "Object" :
51
- return {
52
- TAG: "InlineRecord",
53
- _0: schema._0.map(convertField)
54
- };
51
+ let fields = schema._0;
52
+ if (fields.length === 0) {
53
+ return "JSON";
54
+ } else {
55
+ return {
56
+ TAG: "InlineRecord",
57
+ _0: fields.map(convertField)
58
+ };
59
+ }
55
60
  case "Array" :
56
61
  return {
57
62
  TAG: "Array",
@@ -258,13 +263,21 @@ function convertToIrTypeDef(namedSchema, schemasDict, tagsDict, skipSchemaSet) {
258
263
  }
259
264
  let fields = namedSchema.schema;
260
265
  let kind;
261
- kind = typeof fields !== "object" || fields._tag !== "Object" ? ({
266
+ if (typeof fields !== "object" || fields._tag !== "Object") {
267
+ kind = {
262
268
  TAG: "AliasDef",
263
269
  _0: convertType(namedSchema.schema)
264
- }) : ({
265
- TAG: "RecordDef",
266
- _0: fields._0.map(convertField)
267
- });
270
+ };
271
+ } else {
272
+ let fields$1 = fields._0;
273
+ kind = fields$1.length > 0 ? ({
274
+ TAG: "RecordDef",
275
+ _0: fields$1.map(convertField)
276
+ }) : ({
277
+ TAG: "AliasDef",
278
+ _0: convertType(namedSchema.schema)
279
+ });
280
+ }
268
281
  let annotations = shouldSkipSchema ? ["GenType"] : [
269
282
  "GenType",
270
283
  "Schema"