Skip to content

Commit 8fd5a1c

Browse files
authored
Merge pull request #758 from json-schema-tools/fix/bump-deps-and-uncomment-test
fix: tests were commented out rip
2 parents b783da5 + 327f46d commit 8fd5a1c

File tree

8 files changed

+168
-827
lines changed

8 files changed

+168
-827
lines changed

package-lock.json

Lines changed: 105 additions & 105 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
"!build/**/*.test.*"
2828
],
2929
"devDependencies": {
30-
"@json-schema-tools/dereferencer": "^1.5.7",
31-
"@json-schema-tools/meta-schema": "^1.7.0",
30+
"@json-schema-tools/dereferencer": "^1.6.3",
31+
"@json-schema-tools/meta-schema": "^1.7.5",
3232
"@types/jest": "^29.2.0",
3333
"@types/lodash.camelcase": "^4.3.7",
3434
"@types/lodash.deburr": "^4.1.7",
@@ -46,9 +46,9 @@
4646
"typescript": "^5.4.5"
4747
},
4848
"dependencies": {
49-
"@json-schema-tools/referencer": "^1.1.2",
50-
"@json-schema-tools/titleizer": "^1.0.8",
51-
"@json-schema-tools/traverse": "^1.10.1",
49+
"@json-schema-tools/referencer": "^1.1.3",
50+
"@json-schema-tools/titleizer": "^1.0.9",
51+
"@json-schema-tools/traverse": "^1.10.4",
5252
"lodash.camelcase": "^4.3.0",
5353
"lodash.deburr": "^4.1.0",
5454
"lodash.snakecase": "^4.1.1",

src/integration-tests/expecteds/go/openrpc.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,16 @@ func (o DependenciesSet) MarshalJSON() ([]byte, error) {
255255
}
256256
type Dependencies map[string]interface{}
257257
type Enum []AlwaysTrue
258-
type SimpleTypes interface{}
258+
type SimpleTypes string
259+
const (
260+
SimpleTypesEnum0 SimpleTypes = "array"
261+
SimpleTypesEnum1 SimpleTypes = "boolean"
262+
SimpleTypesEnum2 SimpleTypes = "integer"
263+
SimpleTypesEnum3 SimpleTypes = "null"
264+
SimpleTypesEnum4 SimpleTypes = "number"
265+
SimpleTypesEnum5 SimpleTypes = "object"
266+
SimpleTypesEnum6 SimpleTypes = "string"
267+
)
259268
type ArrayOfSimpleTypes []SimpleTypes
260269
type Type struct {
261270
SimpleTypes *SimpleTypes
@@ -727,4 +736,4 @@ type OpenrpcDocument struct {
727736
Methods *Methods `json:"methods"`
728737
Components *Components `json:"components,omitempty"`
729738
Schema *MetaSchema `json:"$schema,omitempty"`
730-
}
739+
}

src/integration-tests/expecteds/py/openrpc.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,14 @@ class MethodObjectParamStructure(Enum):
206206

207207
Enum = NewType("Enum", List[AlwaysTrue])
208208

209-
SimpleTypes = NewType("SimpleTypes", Any)
209+
class SimpleTypes(Enum):
210+
Array = 0
211+
Boolean = 1
212+
Integer = 2
213+
Null = 3
214+
Number = 4
215+
Object = 5
216+
String = 6
210217

211218
ArrayOfSimpleTypes = NewType("ArrayOfSimpleTypes", List[SimpleTypes])
212219

@@ -425,4 +432,4 @@ class OpenrpcDocument(TypedDict):
425432
servers: Optional[Servers]
426433
methods: undefined
427434
components: Optional[Components]
428-
$schema: Optional[MetaSchema]
435+
$schema: Optional[MetaSchema]

src/integration-tests/expecteds/rs/openrpc.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,23 @@ pub enum DependenciesSet {
278278
}
279279
pub type Dependencies = HashMap<String, DependenciesSet>;
280280
pub type Enum = Vec<AlwaysTrue>;
281-
pub type SimpleTypes = serde_json::Value;
281+
#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)]
282+
pub enum SimpleTypes {
283+
#[serde(rename = "array")]
284+
Array,
285+
#[serde(rename = "boolean")]
286+
Boolean,
287+
#[serde(rename = "integer")]
288+
Integer,
289+
#[serde(rename = "null")]
290+
Null,
291+
#[serde(rename = "number")]
292+
Number,
293+
#[serde(rename = "object")]
294+
Object,
295+
#[serde(rename = "string")]
296+
String,
297+
}
282298
pub type ArrayOfSimpleTypes = Vec<SimpleTypes>;
283299
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
284300
#[serde(untagged)]
@@ -642,4 +658,4 @@ pub struct OpenrpcDocument {
642658
pub components: Option<Components>,
643659
#[serde(rename = "$schema", skip_serializing_if = "Option::is_none")]
644660
pub schema: Option<MetaSchema>,
645-
}
661+
}

src/integration-tests/expecteds/ts/openrpc.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export interface PatternProperties { [key: string]: any; }
161161
export type DependenciesSet = JSONSchema | StringArray;
162162
export interface Dependencies { [key: string]: any; }
163163
export type Enum = AlwaysTrue[];
164-
export type SimpleTypes = any;
164+
export type SimpleTypes = "array" | "boolean" | "integer" | "null" | "number" | "object" | "string";
165165
export type ArrayOfSimpleTypes = SimpleTypes[];
166166
export type Type = SimpleTypes | ArrayOfSimpleTypes;
167167
export type Format = string;
@@ -378,4 +378,4 @@ export interface OpenrpcDocument {
378378
components?: Components;
379379
$schema?: MetaSchema;
380380
[regex: string]: SpecificationExtension | any;
381-
}
381+
}

src/integration-tests/runner.test.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ const getTestCaseBase = async (names: string[], languages: string[]): Promise<Te
3737
const testCases: TestCase[] = [];
3838

3939
languages.forEach((language) => {
40-
if (language !== "ts") { return; }
40+
// if (language !== "ts") { return; }
4141

4242
names.forEach((name) => {
43-
if (name !== "json-schema") { return; }
43+
// if (name !== "boolean-schemas") { return; }
4444

4545
promises.push(readFile(`${testCaseDir}/${name}.json`, "utf8")
4646
.then((fileContents) => {
@@ -69,14 +69,21 @@ const addExpectedTypings = async (tcs: TestCase[]): Promise<TestCase[]> => {
6969
};
7070

7171
const derefTestCases = async (tcs: TestCase[]): Promise<TestCase[]> => {
72-
const derefPromises: any[] = [];
73-
74-
tcs.forEach((tc) => {
75-
const dereffer = new Dereferencer(tc.schema);
76-
derefPromises.push(dereffer.resolve().then((s) => tc.schema = s));
77-
});
72+
for (const tc of tcs) {
73+
let s = tc.schema as JSONSchema[];
74+
const wasArray = tc.schema instanceof Array;
75+
if (wasArray === false) {
76+
s = [s];
77+
}
78+
tc.schema = await Promise.all(s.map((_s) => {
79+
const dereffer = new Dereferencer(_s);
80+
return dereffer.resolve();
81+
}));
7882

79-
await Promise.all(derefPromises);
83+
if (wasArray === false) {
84+
tc.schema = tc.schema[0];
85+
}
86+
}
8087

8188
return tcs;
8289
};

0 commit comments

Comments
 (0)