Skip to content

Commit f5bb5dc

Browse files
committed
added more examples
1 parent af72729 commit f5bb5dc

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,27 @@ Download `swagger.js` and `shred.bundle.js` into your lib folder
9292
</script>
9393
```
9494

95+
### Need to send an object to your API via POST or PUT?
96+
```js
97+
var body = {
98+
id: 100,
99+
name: "dog"};
100+
101+
swagger.apis.pet.addPet({body: JSON.stringify(body)});
102+
```
103+
104+
### Sending XML in as a payload to your API?
105+
```js
106+
var body = "<Pet><id>2</id><name>monster</name></Pet>";
107+
108+
swagger.apis.pet.addPet({body: body},{requestContentType:"application/xml"});
109+
```
110+
111+
### Need XML response?
112+
```js
113+
swagger.apis.pet.getPetById({petId:1},{responseContentType:"application/xml"});
114+
```
115+
95116
### How does it work?
96117
The swagger javascript client reads the swagger api definition directly from the server. As it does, it constructs a client based on the api definition, which means it is completely dynamic. It even reads the api text descriptions (which are intended for humans!) and provides help if you need it:
97118

0 commit comments

Comments
 (0)