request-typer
Advanced tools
Comparing version 1.2.5 to 1.3.0
@@ -12,5 +12,5 @@ "use strict"; | ||
id: Parameter_1.Parameter.Path(schema_1.Schema.String()), | ||
}, { | ||
}, schema_1.Schema.Object({ | ||
user: schema_1.Schema.Object({ id: schema_1.Schema.String() }), | ||
}); | ||
})); | ||
(0, chai_1.expect)(request.method).to.be.eq("get"); | ||
@@ -21,4 +21,4 @@ (0, chai_1.expect)(request.operationId).to.be.eq("getUser"); | ||
(0, chai_1.expect)(request.parameters.id.schema.type).to.be.eq("string"); | ||
(0, chai_1.expect)(request.response.user.type).to.be.eq("object"); | ||
(0, chai_1.expect)(request.response.user.properties.id.type).to.be.eq("string"); | ||
(0, chai_1.expect)(request.response.properties.user.type).to.be.eq("object"); | ||
(0, chai_1.expect)(request.response.properties.user.properties.id.type).to.be.eq("string"); | ||
}); | ||
@@ -30,5 +30,5 @@ }); | ||
id: Parameter_1.Parameter.Body(schema_1.Schema.String()), | ||
}, { | ||
}, schema_1.Schema.Object({ | ||
user: schema_1.Schema.Object({ id: schema_1.Schema.String() }), | ||
}); | ||
})); | ||
(0, chai_1.expect)(request.method).to.be.eq("post"); | ||
@@ -39,4 +39,4 @@ (0, chai_1.expect)(request.operationId).to.be.eq("createUser"); | ||
(0, chai_1.expect)(request.parameters.id.schema.type).to.be.eq("string"); | ||
(0, chai_1.expect)(request.response.user.type).to.be.eq("object"); | ||
(0, chai_1.expect)(request.response.user.properties.id.type).to.be.eq("string"); | ||
(0, chai_1.expect)(request.response.properties.user.type).to.be.eq("object"); | ||
(0, chai_1.expect)(request.response.properties.user.properties.id.type).to.be.eq("string"); | ||
}); | ||
@@ -48,5 +48,5 @@ }); | ||
id: Parameter_1.Parameter.Path(schema_1.Schema.String()), | ||
}, { | ||
}, schema_1.Schema.Object({ | ||
user: schema_1.Schema.Object({ id: schema_1.Schema.String() }), | ||
}); | ||
})); | ||
(0, chai_1.expect)(request.method).to.be.eq("put"); | ||
@@ -57,4 +57,4 @@ (0, chai_1.expect)(request.operationId).to.be.eq("updateUser"); | ||
(0, chai_1.expect)(request.parameters.id.schema.type).to.be.eq("string"); | ||
(0, chai_1.expect)(request.response.user.type).to.be.eq("object"); | ||
(0, chai_1.expect)(request.response.user.properties.id.type).to.be.eq("string"); | ||
(0, chai_1.expect)(request.response.properties.user.type).to.be.eq("object"); | ||
(0, chai_1.expect)(request.response.properties.user.properties.id.type).to.be.eq("string"); | ||
}); | ||
@@ -66,5 +66,5 @@ }); | ||
id: Parameter_1.Parameter.Path(schema_1.Schema.String()), | ||
}, { | ||
}, schema_1.Schema.Object({ | ||
user: schema_1.Schema.Object({ id: schema_1.Schema.String() }), | ||
}); | ||
})); | ||
(0, chai_1.expect)(request.method).to.be.eq("patch"); | ||
@@ -75,4 +75,4 @@ (0, chai_1.expect)(request.operationId).to.be.eq("updateUser"); | ||
(0, chai_1.expect)(request.parameters.id.schema.type).to.be.eq("string"); | ||
(0, chai_1.expect)(request.response.user.type).to.be.eq("object"); | ||
(0, chai_1.expect)(request.response.user.properties.id.type).to.be.eq("string"); | ||
(0, chai_1.expect)(request.response.properties.user.type).to.be.eq("object"); | ||
(0, chai_1.expect)(request.response.properties.user.properties.id.type).to.be.eq("string"); | ||
}); | ||
@@ -84,5 +84,5 @@ }); | ||
id: Parameter_1.Parameter.Path(schema_1.Schema.String()), | ||
}, { | ||
}, schema_1.Schema.Object({ | ||
success: schema_1.Schema.Boolean(), | ||
}); | ||
})); | ||
(0, chai_1.expect)(request.method).to.be.eq("delete"); | ||
@@ -93,5 +93,5 @@ (0, chai_1.expect)(request.operationId).to.be.eq("deleteUser"); | ||
(0, chai_1.expect)(request.parameters.id.schema.type).to.be.eq("string"); | ||
(0, chai_1.expect)(request.response.success.type).to.be.eq("boolean"); | ||
(0, chai_1.expect)(request.response.properties.success.type).to.be.eq("boolean"); | ||
}); | ||
}); | ||
}); |
@@ -9,3 +9,3 @@ "use strict"; | ||
const Responses = { | ||
User: { | ||
User: __1.Schema.Object({ | ||
id: __1.Schema.String(), | ||
@@ -16,3 +16,3 @@ name: __1.Schema.String(), | ||
fields: __1.Schema.Dict(__1.Schema.String()), | ||
}, | ||
}), | ||
}; | ||
@@ -19,0 +19,0 @@ const httpRequestSchemas = [ |
import { RequestParameter } from "./parameter"; | ||
import { AllSchema, UndefinedPropertyToOptional, Resolve } from "./schema"; | ||
import { ObjectSchema, ObjectProperties, UndefinedPropertyToOptional, Resolve } from "./schema"; | ||
export declare type Method = "get" | "post" | "put" | "patch" | "delete"; | ||
@@ -7,5 +7,3 @@ export declare type Parameters = { | ||
}; | ||
export declare type ResponseBody = { | ||
[key in string]: AllSchema; | ||
}; | ||
export declare type ResponseBody = ObjectSchema<ObjectProperties>; | ||
export declare type HTTPRequest<M extends Method, P extends Parameters, R extends ResponseBody> = { | ||
@@ -12,0 +10,0 @@ method: M; |
@@ -32,3 +32,3 @@ "use strict"; | ||
this.responseSchemaKeyValuePairs.forEach(([key, value]) => { | ||
schemas[key] = this.createSchema({ type: "object", properties: value, options: {}, definition: "" }); | ||
schemas[key] = this.createSchema(value); | ||
}); | ||
@@ -79,2 +79,3 @@ return { schemas }; | ||
schema: (() => { | ||
console.log(requestSchema); | ||
const schemaName = this.getResponseBodySchemaName(requestSchema.response); | ||
@@ -85,8 +86,3 @@ return schemaName | ||
} | ||
: this.createSchema({ | ||
type: "object", | ||
properties: requestSchema.response, | ||
options: {}, | ||
definition: "", | ||
}); | ||
: this.createSchema(requestSchema.response); | ||
})(), | ||
@@ -99,2 +95,3 @@ }, | ||
createSchema(schema) { | ||
console.log(schema); | ||
const nullable = schema.options.nullable; | ||
@@ -101,0 +98,0 @@ switch (schema.type) { |
{ | ||
"name": "request-typer", | ||
"version": "1.2.5", | ||
"version": "1.3.0", | ||
"description": "Make typed request schema and build OpenAPI Specification", | ||
@@ -5,0 +5,0 @@ "files": [ |
56271
1074