Skip to content

Commit 61db346

Browse files
authored
Merge pull request #6 from hadiindrawan/dev
change schema file
2 parents 8240070 + 3f90e1b commit 61db346

File tree

5 files changed

+24
-16
lines changed

5 files changed

+24
-16
lines changed

lib/component/json_schema.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ async function writeJsonSchema(element, jsonSchemaPath) {
1010
// A variable called 'method' is created and assigned the value obtained from the 'method' property of the 'element.request' object.
1111
let method = element.request.method;
1212
// check if file exists
13-
isFileExisted(jsonSchemaPath, method + '_' + name + '.json')
13+
isFileExisted(jsonSchemaPath, method + '_' + name + '.schema.js')
1414
.then((data) => {
1515
if (!data[0]) {
1616
// create file test
17-
fs.writeFile(jsonSchemaPath + '/' + method + '_' +name + '.json',
17+
fs.writeFile(jsonSchemaPath + '/' + method + '_' +name + '.schema.js',
1818
fs.readFileSync(basePath() + 'lib/template/json_responses.dot', 'utf8'), function (err) { if (err) throw err; });
1919
}
2020
})

lib/component/pages.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ async function writePages(element, path, jsonSchemaRelativePath, helperPath, mai
133133
}
134134

135135
code = code.replace("{{objectBody}}", bodyRaw)
136-
code = code.replace("{{jsonSchemaPath}}", jsonSchemaRelativePath + '/' + method + '_'+ name + '.json')
136+
code = code.replace("{{jsonSchemaPath}}", jsonSchemaRelativePath + '/' + method + '_'+ name + '.schema.js')
137137
code = code.replace("{{bodyFunc}}", bodyFunc)
138138
code = code.replace("{{rawAtt}}", attKey)
139139
code = code.replace("{{helperPath}}", helperPath)

lib/template/json_responses.dot

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1-
{
2-
"success":
3-
{
4-
"example": ""
5-
},
6-
"failed":
7-
{
8-
"example": ""
1+
class schema {
2+
json() {
3+
const json =
4+
{
5+
"success":
6+
{
7+
"example": ""
8+
},
9+
"failed":
10+
{
11+
"example": ""
12+
}
13+
}
14+
return json
915
}
10-
}
16+
}
17+
18+
module.exports = schema

lib/template/request.dot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const chai = require('chai')
22
chai.use(require('chai-http'))
33
const main = require('{{mainpagesPath}}');
4-
const json_responses = require('{{jsonSchemaPath}}');
4+
const schema = require('{{jsonSchemaPath}}');
55
const requestHelper = require('{{helperPath}}');
66
require('dotenv').config()
77

@@ -38,7 +38,7 @@ class request extends main {
3838

3939
// This method used for provide expectation and return json schema
4040
expect(cases="success") {
41-
return new requestHelper().getSchema(json_responses, cases)
41+
return new requestHelper().getSchema(new schema().json(), cases)
4242
}
4343
}
4444

lib/template/requestWithAttach.dot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const chai = require('chai')
22
chai.use(require('chai-http'))
33
const main = require('{{mainpagesPath}}');
4-
const json_responses = require('{{jsonSchemaPath}}');
4+
const schema = require('{{jsonSchemaPath}}');
55
const requestHelper = require('{{helperPath}}');
66
require('dotenv').config()
77

@@ -68,7 +68,7 @@ class request extends main {
6868

6969
// This method used for provide expectation and return json schema
7070
expect(cases="success") {
71-
return new requestHelper().getSchema(json_responses, cases)
71+
return new requestHelper().getSchema(new schema().json(), cases)
7272
}
7373
}
7474

0 commit comments

Comments
 (0)