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

Commit b8ef38b

Browse files
committed
"Hello World"-example should now match its spec
1 parent a5c33c1 commit b8ef38b

File tree

8 files changed

+13
-13
lines changed

8 files changed

+13
-13
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ 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);
49+
var hello = util.format('{ "message": "Hello, %s" }', name);
5050
res.json(hello);
5151
}
5252
```
@@ -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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ 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!';
38+
var name = req.swagger.params.name.value || 'stranger';
39+
var hello = util.format('{ "message": "Hello, %s" }', name);
4040
res.json(hello);
4141
}
4242
```

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
@@ -37,7 +37,7 @@ module.exports = {
3737
function hello(req, res) {
3838
// variables defined in the Swagger document can be referenced using req.swagger.params.{parameter_name}
3939
var name = req.swagger.params.name.value || 'stranger';
40-
var hello = util.format('Hello, %s!', name);
40+
var hello = util.format('{ "message": "Hello, %s!" }', name);
4141

4242
// this sends back a JSON response which is a single string
4343
res.json(hello);

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
@@ -37,7 +37,7 @@ module.exports = {
3737
function hello(req, res) {
3838
// variables defined in the Swagger document can be referenced using req.swagger.params.{parameter_name}
3939
var name = req.swagger.params.name.value || 'stranger';
40-
var hello = util.format('Hello, %s!', name);
40+
var hello = util.format('{ "message": "Hello, %s!" }', name);
4141

4242
// this sends back a JSON response which is a single string
4343
res.json(hello);

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)