Skip to content

Commit 0558c6b

Browse files
committed
Merge pull request swagger-api#676 from jmwohl/readme-example-consistency
Updated variable naming for clarity and consistency
2 parents a6a791a + d407fd4 commit 0558c6b

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ bower install swagger-js
2323

2424
Then let swagger do the work!
2525
```js
26-
var client = require('swagger-client');
26+
var Swagger = require('swagger-client');
2727

28-
var swagger = new client({
28+
var client = new Swagger({
2929
url: 'http://petstore.swagger.io/v2/swagger.json',
3030
success: function() {
31-
swagger.pet.getPetById({petId:7},{responseContentType: 'application/json'},function(pet){
31+
client.pet.getPetById({petId:7},{responseContentType: 'application/json'},function(pet){
3232
console.log('pet', pet);
3333
});
3434
}
@@ -71,12 +71,12 @@ That's it! You'll get a JSON response with the default callback handler:
7171
You need to pass success and error functions to do anything reasonable with the responses:
7272

7373
```js
74-
var client = require('swagger-client');
74+
var Swagger = require('swagger-client');
7575

76-
var swagger = new client({
76+
var client = new Swagger({
7777
url: 'http://petstore.swagger.io/v2/swagger.json',
7878
success: function() {
79-
swagger.pet.getPetById({petId:7}, function(success){
79+
client.pet.getPetById({petId:7}, function(success){
8080
console.log('succeeded and returned this object: ' + success.obj);
8181
},
8282
function(error) {
@@ -109,19 +109,19 @@ new Swagger({
109109
Need to pass an API key? Configure one as a query string:
110110

111111
```js
112-
client.clientAuthorizations.add("apiKey", new client.ApiKeyAuthorization("api_key","special-key","query"));
112+
client.clientAuthorizations.add("apiKey", new Swagger.ApiKeyAuthorization("api_key","special-key","query"));
113113
```
114114

115115
...or with a header:
116116

117117
```js
118-
client.clientAuthorizations.add("apiKey", new client.ApiKeyAuthorization("api_key","special-key","header"));
118+
client.clientAuthorizations.add("apiKey", new Swagger.ApiKeyAuthorization("api_key","special-key","header"));
119119
```
120120

121121
...or with the swagger-client constructor:
122122

123123
```js
124-
var swagger = new client({
124+
var client = new Swagger({
125125
url: 'http://example.com/spec.json',
126126
success: function() {},
127127
authorizations : {
@@ -140,12 +140,12 @@ Download `browser/swagger-client.js` into your webapp:
140140
```js
141141
<script src='browser/swagger-client.js' type='text/javascript'></script>
142142
<script type="text/javascript">
143-
// initialize swagger, point to a resource listing
144-
window.swagger = new SwaggerClient({
143+
// initialize swagger client, point to a resource listing
144+
window.client = new SwaggerClient({
145145
url: "http://petstore.swagger.io/v2/swagger.json",
146146
success: function() {
147147
// upon connect, fetch a pet and set contents to element "mydata"
148-
swagger.pet.getPetById({petId:1},{responseContentType: 'application/json'}, function(data) {
148+
client.pet.getPetById({petId:1},{responseContentType: 'application/json'}, function(data) {
149149
document.getElementById("mydata").innerHTML = JSON.stringify(data.obj);
150150
});
151151
}
@@ -163,19 +163,19 @@ var pet = {
163163
id: 100,
164164
name: "dog"};
165165

166-
swagger.pet.addPet({body: pet});
166+
client.pet.addPet({body: pet});
167167
```
168168

169169
### Sending XML in as a payload to your API?
170170
```js
171171
var pet = "<Pet><id>2</id><name>monster</name></Pet>";
172172

173-
swagger.pet.addPet({body: pet}, {requestContentType:"application/xml"});
173+
client.pet.addPet({body: pet}, {requestContentType:"application/xml"});
174174
```
175175

176176
### Need XML response?
177177
```js
178-
swagger.pet.getPetById({petId:1}, {responseContentType:"application/xml"});
178+
client.pet.getPetById({petId:1}, {responseContentType:"application/xml"});
179179
```
180180

181181
### Custom request signing

0 commit comments

Comments
 (0)