mirror of
				https://github.com/Redocly/redoc.git
				synced 2025-10-30 23:37:28 +03:00 
			
		
		
		
	Merge commit '5111abf1d4476edf204d0f7384b5b8247d5e661e' into releases
This commit is contained in:
		
						commit
						41add7fbf8
					
				|  | @ -97,7 +97,7 @@ ReDoc makes use of the following [vendor extensions](http://swagger.io/specifica | |||
|   * **number**: A fixed number of pixels to be used as offset; | ||||
|   * **selector**: selector of the element to be used for specifying the offset. The distance from the top of the page to the element's bottom will be used as offset; | ||||
|   * **function**: A getter function. Must return a number representing the offset (in pixels); | ||||
| * `suppress-warnings` - if set, warnings are not rendered at the top of page (they still are logged to the console). | ||||
| * `suppress-warnings` - if set, warnings are not rendered at the top of documentation (they still are logged to the console). | ||||
| 
 | ||||
| ## Advanced usage | ||||
| Instead of adding `spec-url` attribute to the `<redoc>` element you can initialize ReDoc via globally exposed `Redoc` object: | ||||
|  | @ -105,12 +105,13 @@ Instead of adding `spec-url` attribute to the `<redoc>` element you can initiali | |||
| Redoc.init(specUrl, options) | ||||
| ``` | ||||
| 
 | ||||
| `options` is javascript object with camel-cased version of options names as the keys. For example: | ||||
| `options` is javascript object with camel-cased version of options names as the keys, e.g.: | ||||
| ```js | ||||
| Redoc.init('http://petstore.swagger.io/v2/swagger.json', { | ||||
|   scrollYOffset: 50 | ||||
| }) | ||||
| ``` | ||||
| 
 | ||||
| ----------- | ||||
| ## Running locally | ||||
| 1. Clone repository | ||||
|  |  | |||
|  | @ -4,10 +4,22 @@ | |||
| require('shelljs/global'); | ||||
| set('-e'); | ||||
| 
 | ||||
| function isPR() { | ||||
|   return process.env.TRAVIS_PULL_REQUEST && process.env.TRAVIS_PULL_REQUEST !== 'false'; | ||||
| } | ||||
| 
 | ||||
| if (process.env.JOB === 'e2e-guru') { | ||||
|   if (isPR()) { | ||||
|     console.log('Skiping E2E tests on PR'); | ||||
|     return; | ||||
|   } | ||||
|   exec('npm run e2e'); | ||||
| } else { | ||||
|   exec('npm run unit'); | ||||
|   if (isPR()) { | ||||
|     console.log('Skiping E2E tests on PR'); | ||||
|     return; | ||||
|   } | ||||
|   console.log('Starting Basic E2E'); | ||||
|   exec('npm run e2e'); | ||||
| } | ||||
|  |  | |||
|  | @ -1,8 +1,8 @@ | |||
| 'use strict'; | ||||
| import './components/Redoc/redoc-initial-styles.css!css'; | ||||
| import 'dropkickjs/build/css/dropkick.css!css'; | ||||
| import 'prismjs/themes/prism-dark.css!css'; | ||||
| import 'hint.css/hint.base.css!css'; | ||||
| import './components/Redoc/redoc-initial-styles.css!css'; | ||||
| import { redocVersion } from './version.js'; | ||||
| 
 | ||||
| import { Redoc } from './components/index'; | ||||
|  |  | |||
|  | @ -42,16 +42,21 @@ export class SpecManager { | |||
| 
 | ||||
|   /* calculate common used values */ | ||||
|   init() { | ||||
|     let urlParts = this._url ? urlParse(this._url) : {}; | ||||
|     let schemes = this._schema.schemes; | ||||
|     let protocol; | ||||
|     if (!this._schema.schemes || !this._schema.schemes.length) { | ||||
|       protocol = this._url ? urlParse(this._url).protocol : 'http'; | ||||
|     if (!schemes || !schemes.length) { | ||||
|       // url parser incudles ':' in protocol so remove it
 | ||||
|       protocol = urlParts.protocol ? urlParts.protocol.slice(0, -1) : 'http'; | ||||
|     } else { | ||||
|       protocol = this._schema.schemes[0]; | ||||
|       if (protocol === 'http' && this._schema.schemes.indexOf('https') >= 0) { | ||||
|       protocol = schemes[0]; | ||||
|       if (protocol === 'http' && schemes.indexOf('https') >= 0) { | ||||
|         protocol = 'https'; | ||||
|       } | ||||
|     } | ||||
|     this.apiUrl = protocol + '://' + this._schema.host + this._schema.basePath; | ||||
| 
 | ||||
|     let host = this._schema.host || urlParts.host; | ||||
|     this.apiUrl = protocol + '://' + host + this._schema.basePath; | ||||
|     if (this.apiUrl.endsWith('/')) { | ||||
|       this.apiUrl = this.apiUrl.substr(0, this.apiUrl.length - 1); | ||||
|     } | ||||
|  |  | |||
|  | @ -1,7 +1,7 @@ | |||
| { | ||||
|   "name": "redoc", | ||||
|   "description": "Swagger-generated API Reference Documentation", | ||||
|   "version": "1.0.0", | ||||
|   "version": "1.0.1", | ||||
|   "repository": { | ||||
|     "type": "git", | ||||
|     "url": "git://github.com/Rebilly/ReDoc" | ||||
|  |  | |||
|  | @ -59,6 +59,20 @@ describe('Utils', () => { | |||
|         specMgr.apiUrl.should.be.equal('https://petstore.swagger.io/v2'); | ||||
|       }); | ||||
| 
 | ||||
|       it('should substitute api scheme when spec schemes are undefined', () => { | ||||
|         specMgr._schema.schemes = undefined; | ||||
|         specMgr._url = 'https://petstore.swagger.io/v2'; | ||||
|         specMgr.init(); | ||||
|         specMgr.apiUrl.should.be.equal('https://petstore.swagger.io/v2'); | ||||
|       }); | ||||
| 
 | ||||
|       it('should substitute api host when spec host is undefined', () => { | ||||
|         specMgr._schema.host = undefined; | ||||
|         specMgr._url = 'https://petstore.swagger.io/v2'; | ||||
|         specMgr.init(); | ||||
|         specMgr.apiUrl.should.be.equal('https://petstore.swagger.io/v2'); | ||||
|       }); | ||||
| 
 | ||||
|       describe('byPointer method', () => { | ||||
|         it('should return correct schema part', ()=> { | ||||
|           let part = specMgr.byPointer('/tags/3'); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user