Skip to content

Commit 0cb1ce9

Browse files
author
kawasima
committed
Bump up lerna to v5
1 parent 7483d60 commit 0cb1ce9

File tree

6 files changed

+19264
-5590
lines changed

6 files changed

+19264
-5590
lines changed

Diff for: lerna.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "0.1.10",
2+
"version": "0.1.11",
33
"npmClient": "npm",
44
"command": {
55
"publish": {

Diff for: lib/core/src/base.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ class OrSpec extends Spec {
202202

203203
const forms = this.forms;
204204
const gs = this.preds.map((pred, i) => [pred, forms[i]]);
205-
return g.oneOf(gs.map(([pred, form]) => gensub(pred, overrides, /*TODO*/path, rmap, form)));
205+
return g.oneOf.apply(null, gs.map(([pred, form]) => gensub(pred, overrides, /*TODO*/path, rmap, form)));
206206
}
207207

208208
explain(path, via, in_, x) {

Diff for: lib/openapi/src/__tests__/core.test.js

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
const s = require('@json-spec/core');
2+
const gen = require('@json-spec/core/gen');
3+
const { parseApiSpec, readSpec } = require('../core');
4+
5+
describe('openapi', () => {
6+
test('oneOf', async () => {
7+
const spec = await readSpec({
8+
openapi: "3.0",
9+
paths: {
10+
"/": {
11+
"get": {
12+
responses: {
13+
"200": {
14+
content: {
15+
"application/json": {
16+
schema: {
17+
oneOf: [
18+
{
19+
type: "object",
20+
properties: {
21+
name: {
22+
type: "string"
23+
}
24+
},
25+
required: ["name"]
26+
},
27+
{
28+
type: "object",
29+
properties: {
30+
age: {
31+
type: "integer"
32+
}
33+
},
34+
required: ["age"]
35+
}
36+
]
37+
}
38+
}
39+
}
40+
}
41+
}
42+
}
43+
}
44+
}
45+
}, {
46+
}, function({method, path, specs}) {
47+
const spec = specs.response["200"]["application/json"];
48+
console.log(spec);
49+
console.log(gen.sample(s.gen(spec)));
50+
return {
51+
method,
52+
path,
53+
specs
54+
}
55+
});
56+
57+
})
58+
})

Diff for: lib/openapi/src/core.js

+3
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ function schemaToSpec(schema, jsonSpecs) {
6060
if (schema.allOf) {
6161
schema = mergeSchema(schema.allOf);
6262
}
63+
if (schema.oneOf) {
64+
return s.or.apply(null, schema.oneOf.map(v => schemaToSpec(v, jsonSpecs)));
65+
}
6366
const spec = parseJsonSchema(schema);
6467
if (spec) return spec;
6568

0 commit comments

Comments
 (0)