forked from seriousme/fastify-openapi-glue
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathservice.js
More file actions
26 lines (23 loc) · 686 Bytes
/
Copy pathservice.js
File metadata and controls
26 lines (23 loc) · 686 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// an example of implementation of the operations in the openapi specification
class Service {
constructor() {}
async getPetById(req, resp) {
console.log("getPetById", req.params.petId);
if (req.params.petId === 0) {
// missing required data on purpose !
// this will trigger a server error on serialization
return { pet: "Doggie the dog" };
} else {
return {
id: req.params.petId,
name: "Kitty the cat",
photoUrls: {
photoUrl:
"https://en.wikipedia.org/wiki/Cat#/media/File:Kittyply_edit1.jpg"
},
status: "available"
};
}
}
}
module.exports = config => new Service();