Skip to content

Commit

Permalink
fix: add response object for ping
Browse files Browse the repository at this point in the history
Signed-off-by: Raymond Feng <[email protected]>
  • Loading branch information
raymondfeng committed Sep 24, 2018
1 parent 74bfccb commit 2258e98
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/controllers/ping.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,41 @@ import {Request, RestBindings} from '@loopback/rest';
import {get} from '@loopback/openapi-v3';
import {inject} from '@loopback/context';

const PING_RESPONSE = {
description: 'Ping Response',
content: {
'application/json': {
schema: {
type: 'object',
properties: {
greeting: {type: 'string'},
date: {type: 'string'},
url: {type: 'string'},
headers: {
type: 'object',
patternProperties: {
'^.*$': {type: 'string'},
},
additionalProperties: false,
},
},
},
},
},
};

/**
* A simple controller to bounce back http requests
*/
export class PingController {
constructor(@inject(RestBindings.Http.REQUEST) private req: Request) {}

// Map to `GET /ping`
@get('/ping')
@get('/ping', {
responses: {
'200': PING_RESPONSE,
},
})
ping(): object {
return {
greeting: 'Hello from LoopBack',
Expand Down

2 comments on commit 2258e98

@marioestradarosa
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@raymondfeng shouldn't this PING_RESPONSE object be part of the generated template lb4 app?

@raymondfeng
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marioestradarosa Good reminder. We'll implement here and push back to the template.

Please sign in to comment.