Skip to content
This repository was archived by the owner on Sep 14, 2022. It is now read-only.

Commit 1f01f6a

Browse files
authored
Merge pull request #475 from meisterlampe/master
"Hello World"-example should match its spec ( Fixes #476 )
2 parents a5c33c1 + 93f6e0f commit 1f01f6a

File tree

8 files changed

+15
-15
lines changed

8 files changed

+15
-15
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ Code your API's business logic in Node.js.
4646
```js
4747
function hello(req, res) {
4848
var name = req.swagger.params.name.value || 'stranger';
49-
var hello = util.format('Hello, %s', name);
50-
res.json(hello);
49+
var hello = util.format('Hello, %s!', name);
50+
res.json({ "message": hello });
5151
}
5252
```
5353

@@ -77,7 +77,7 @@ It just works!
7777

7878
```bash
7979
$ curl http://127.0.0.1:10010/hello?name=Scott
80-
"Hello, Scott!"
80+
{ "message": "Hello, Scott!" }
8181
```
8282

8383
# <a name="installation"></a>Installing the swagger module

docs/controllers.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ Here is the `hello_world.js` implementation for the quick start example. It retr
3535
};
3636
3737
function hello(req, res) {
38-
var name = req.swagger.params.name.value;
39-
var hello = name ? util.format('Hello, %s', name) : 'Hello, stranger!';
40-
res.json(hello);
38+
var name = req.swagger.params.name.value || 'stranger';
39+
var hello = util.format('Hello, %s!', name);
40+
res.json({ "message": hello });
4141
}
4242
```
4343

docs/quick-start.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ First, we create a new swagger project and test a simple "hello world" API.
4242
4343
`curl http://127.0.0.1:10010/hello?name=Scott`
4444
45-
And, you'll get back the response `Hello, Scott`.
45+
And, you'll get back the response `{ "message": "Hello, Scott!" }`.
4646
4747
That's it - You have now created, started and tested your first API project with swagger!
4848

project-skeletons/connect/api/controllers/hello_world.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@ function hello(req, res) {
4040
var hello = util.format('Hello, %s!', name);
4141

4242
// this sends back a JSON response which is a single string
43-
res.json(hello);
43+
res.json({ "message": hello });
4444
}

project-skeletons/connect/test/api/controllers/hello_world.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('controllers', function() {
1818
.end(function(err, res) {
1919
should.not.exist(err);
2020

21-
res.body.should.eql('Hello, stranger!');
21+
res.body.should.eql({ "message": "Hello, stranger!" });
2222

2323
done();
2424
});
@@ -35,7 +35,7 @@ describe('controllers', function() {
3535
.end(function(err, res) {
3636
should.not.exist(err);
3737

38-
res.body.should.eql('Hello, Scott!');
38+
res.body.should.eql({ "message": "Hello, Scott!" });
3939

4040
done();
4141
});

project-skeletons/sails/api/controllers/hello_world.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@ function hello(req, res) {
4040
var hello = util.format('Hello, %s!', name);
4141

4242
// this sends back a JSON response which is a single string
43-
res.json(hello);
43+
res.json({ "message": hello });
4444
}

project-skeletons/sails/test/api/controllers/hello_world.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('controllers', function() {
1717
.end(function(err, res) {
1818
should.not.exist(err);
1919

20-
res.body.should.eql('Hello, stranger!');
20+
res.body.should.eql({ "message": "Hello, stranger!" });
2121

2222
done();
2323
});
@@ -34,7 +34,7 @@ describe('controllers', function() {
3434
.end(function(err, res) {
3535
should.not.exist(err);
3636

37-
res.body.should.eql('Hello, Scott!');
37+
res.body.should.eql({ "message": "Hello, Scott!" });
3838

3939
done();
4040
});

test/project-skeletons/common.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function testFramework(framework) {
8989
debug('Result: %s %j', res.text, res.headers);
9090

9191
res.status.should.eql(200);
92-
res.body.should.eql('Hello, stranger!');
92+
res.body.should.eql({ "message": "Hello, stranger!" });
9393

9494
done();
9595
});
@@ -104,7 +104,7 @@ function testFramework(framework) {
104104
debug('Result: %s %j', res.text, res.headers);
105105

106106
res.status.should.eql(200);
107-
res.body.should.eql('Hello, Scott!');
107+
res.body.should.eql({ "message": "Hello, Scott!" });
108108

109109
done();
110110
});

0 commit comments

Comments
 (0)