Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
210 changes: 105 additions & 105 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"!build/**/*.test.*"
],
"devDependencies": {
"@json-schema-tools/dereferencer": "^1.5.7",
"@json-schema-tools/meta-schema": "^1.7.0",
"@json-schema-tools/dereferencer": "^1.6.3",
"@json-schema-tools/meta-schema": "^1.7.5",
"@types/jest": "^29.2.0",
"@types/lodash.camelcase": "^4.3.7",
"@types/lodash.deburr": "^4.1.7",
Expand All @@ -46,9 +46,9 @@
"typescript": "^5.4.5"
},
"dependencies": {
"@json-schema-tools/referencer": "^1.1.2",
"@json-schema-tools/titleizer": "^1.0.8",
"@json-schema-tools/traverse": "^1.10.1",
"@json-schema-tools/referencer": "^1.1.3",
"@json-schema-tools/titleizer": "^1.0.9",
"@json-schema-tools/traverse": "^1.10.4",
"lodash.camelcase": "^4.3.0",
"lodash.deburr": "^4.1.0",
"lodash.snakecase": "^4.1.1",
Expand Down
13 changes: 11 additions & 2 deletions src/integration-tests/expecteds/go/openrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,16 @@ func (o DependenciesSet) MarshalJSON() ([]byte, error) {
}
type Dependencies map[string]interface{}
type Enum []AlwaysTrue
type SimpleTypes interface{}
type SimpleTypes string
const (
SimpleTypesEnum0 SimpleTypes = "array"
SimpleTypesEnum1 SimpleTypes = "boolean"
SimpleTypesEnum2 SimpleTypes = "integer"
SimpleTypesEnum3 SimpleTypes = "null"
SimpleTypesEnum4 SimpleTypes = "number"
SimpleTypesEnum5 SimpleTypes = "object"
SimpleTypesEnum6 SimpleTypes = "string"
)
type ArrayOfSimpleTypes []SimpleTypes
type Type struct {
SimpleTypes *SimpleTypes
Expand Down Expand Up @@ -727,4 +736,4 @@ type OpenrpcDocument struct {
Methods *Methods `json:"methods"`
Components *Components `json:"components,omitempty"`
Schema *MetaSchema `json:"$schema,omitempty"`
}
}
11 changes: 9 additions & 2 deletions src/integration-tests/expecteds/py/openrpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,14 @@ class MethodObjectParamStructure(Enum):

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

SimpleTypes = NewType("SimpleTypes", Any)
class SimpleTypes(Enum):
Array = 0
Boolean = 1
Integer = 2
Null = 3
Number = 4
Object = 5
String = 6

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

Expand Down Expand Up @@ -425,4 +432,4 @@ class OpenrpcDocument(TypedDict):
servers: Optional[Servers]
methods: undefined
components: Optional[Components]
$schema: Optional[MetaSchema]
$schema: Optional[MetaSchema]
20 changes: 18 additions & 2 deletions src/integration-tests/expecteds/rs/openrpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,23 @@ pub enum DependenciesSet {
}
pub type Dependencies = HashMap<String, DependenciesSet>;
pub type Enum = Vec<AlwaysTrue>;
pub type SimpleTypes = serde_json::Value;
#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq)]
pub enum SimpleTypes {
#[serde(rename = "array")]
Array,
#[serde(rename = "boolean")]
Boolean,
#[serde(rename = "integer")]
Integer,
#[serde(rename = "null")]
Null,
#[serde(rename = "number")]
Number,
#[serde(rename = "object")]
Object,
#[serde(rename = "string")]
String,
}
pub type ArrayOfSimpleTypes = Vec<SimpleTypes>;
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
#[serde(untagged)]
Expand Down Expand Up @@ -642,4 +658,4 @@ pub struct OpenrpcDocument {
pub components: Option<Components>,
#[serde(rename = "$schema", skip_serializing_if = "Option::is_none")]
pub schema: Option<MetaSchema>,
}
}
4 changes: 2 additions & 2 deletions src/integration-tests/expecteds/ts/openrpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export interface PatternProperties { [key: string]: any; }
export type DependenciesSet = JSONSchema | StringArray;
export interface Dependencies { [key: string]: any; }
export type Enum = AlwaysTrue[];
export type SimpleTypes = any;
export type SimpleTypes = "array" | "boolean" | "integer" | "null" | "number" | "object" | "string";
export type ArrayOfSimpleTypes = SimpleTypes[];
export type Type = SimpleTypes | ArrayOfSimpleTypes;
export type Format = string;
Expand Down Expand Up @@ -378,4 +378,4 @@ export interface OpenrpcDocument {
components?: Components;
$schema?: MetaSchema;
[regex: string]: SpecificationExtension | any;
}
}
25 changes: 16 additions & 9 deletions src/integration-tests/runner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ const getTestCaseBase = async (names: string[], languages: string[]): Promise<Te
const testCases: TestCase[] = [];

languages.forEach((language) => {
if (language !== "ts") { return; }
// if (language !== "ts") { return; }

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

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

const derefTestCases = async (tcs: TestCase[]): Promise<TestCase[]> => {
const derefPromises: any[] = [];

tcs.forEach((tc) => {
const dereffer = new Dereferencer(tc.schema);
derefPromises.push(dereffer.resolve().then((s) => tc.schema = s));
});
for (const tc of tcs) {
let s = tc.schema as JSONSchema[];
const wasArray = tc.schema instanceof Array;
if (wasArray === false) {
s = [s];
}
tc.schema = await Promise.all(s.map((_s) => {
const dereffer = new Dereferencer(_s);
return dereffer.resolve();
}));

await Promise.all(derefPromises);
if (wasArray === false) {
tc.schema = tc.schema[0];
}
}

return tcs;
};
Expand Down
Loading