swagger-client
Advanced tools
Comparing version 2.1.21 to 2.1.22
@@ -328,7 +328,17 @@ 'use strict'; | ||
var scheme = window.location.protocol.replace(':',''); | ||
if(this.schemes.indexOf(scheme) !== -1) { | ||
if(scheme === 'https' && this.schemes.indexOf(scheme) === -1) { | ||
// can't call http from https served page in a browser! | ||
helpers.log('Cannot call a http server from https inside a browser!'); | ||
this.scheme = 'http'; | ||
} | ||
else if(this.schemes.indexOf(scheme) !== -1) { | ||
this.scheme = scheme; | ||
} | ||
else { | ||
this.scheme = 'http'; | ||
if(this.schemes.indexOf('https') !== -1) { | ||
this.scheme = 'https'; | ||
} | ||
else { | ||
this.scheme = 'http'; | ||
} | ||
} | ||
@@ -335,0 +345,0 @@ } |
@@ -11,3 +11,3 @@ { | ||
"description": "swagger-client is a javascript client for use with swaggering APIs.", | ||
"version": "2.1.21", | ||
"version": "2.1.22", | ||
"homepage": "http://swagger.io", | ||
@@ -14,0 +14,0 @@ "repository": { |
# Swagger JS library | ||
[![Build Status](https://travis-ci.org/swagger-api/swagger-js.svg?branch=master)](https://travis-ci.org/swagger-api/swagger-js) | ||
[![NPM version](https://badge.fury.io/js/swagger-client.svg)](http://badge.fury.io/js/swagger-client) | ||
@@ -227,2 +228,42 @@ This is the Swagger javascript client for use with [swagger](http://swagger.io) enabled APIs. | ||
### Setting headers | ||
Headers are a type of `parameter`, and can be passed with the other parameters. For example, if you supported translated pet details via the `Accept-Language` header: | ||
```js | ||
"parameters": [ | ||
{ | ||
"name": "petId", | ||
"description": "ID of pet that needs to be fetched", | ||
"required": true, | ||
"type": "integer", | ||
"format": "int64", | ||
"paramType": "path", | ||
"minimum": "1.0", | ||
"defaultValue": 3, | ||
"maximum": "100000.0" | ||
}, | ||
"LanguageHeader": { | ||
"name": "Accept-Language", | ||
"in": "header", | ||
"description": "Specify the user's language", | ||
"required": false, | ||
"type": "string" | ||
} | ||
... | ||
``` | ||
Then you would pass the header value via the parameters ([header parameters are case-insenstive](https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2)): | ||
```js | ||
client.pet.getPetById({ | ||
petId: 7, | ||
'accept-language': 'fr' | ||
}, function(pet){ | ||
console.log('pet', pet); | ||
}); | ||
``` | ||
### Using your own HTTP client | ||
@@ -229,0 +270,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2065135
25401
371