mirror of
				https://github.com/Redocly/redoc.git
				synced 2025-11-04 09:47:31 +03:00 
			
		
		
		
	Added few utils methods
This commit is contained in:
		
							parent
							
								
									2594cf9503
								
							
						
					
					
						commit
						aaa78d7c50
					
				
							
								
								
									
										18
									
								
								lib/utils/JsonPointer.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								lib/utils/JsonPointer.js
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,18 @@
 | 
				
			||||||
 | 
					'use strict';
 | 
				
			||||||
 | 
					import JsonPointerLib from 'json-pointer';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Wrapper for JsonPointer. Provides common operations
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					export class JsonPointer extends JsonPointerLib {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * returns last JsonPointer token
 | 
				
			||||||
 | 
					   * @example
 | 
				
			||||||
 | 
					   * // returns subpath
 | 
				
			||||||
 | 
					   * new JsonPointerHelper.dirName('/path/0/subpath')
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					   static dirName(pointer) {
 | 
				
			||||||
 | 
					     return JsonPointer.parse(pointer).pop();
 | 
				
			||||||
 | 
					   }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										31
									
								
								lib/utils/pipes.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								lib/utils/pipes.js
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,31 @@
 | 
				
			||||||
 | 
					'use strict';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import {Pipe} from 'angular2/angular2';
 | 
				
			||||||
 | 
					import {JsonPointer} from './JsonPointer';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Pipe({
 | 
				
			||||||
 | 
					  name: 'keys'
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
 | 
					export class KeysPipe {
 | 
				
			||||||
 | 
					  transform(obj) {
 | 
				
			||||||
 | 
					    return Object.keys(obj);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Pipe({
 | 
				
			||||||
 | 
					  name: 'values'
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
 | 
					export class ValuesPipe {
 | 
				
			||||||
 | 
					  transform(obj) {
 | 
				
			||||||
 | 
					    return Object.keys(obj).map(key => obj[key]);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Pipe({
 | 
				
			||||||
 | 
					  name: 'jsonPointerEscape'
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
 | 
					export class JsonPointerEscapePipe {
 | 
				
			||||||
 | 
					  transform(str) {
 | 
				
			||||||
 | 
					    return JsonPointer.escape(str);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										3
									
								
								lib/utils/swagger-defs.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								lib/utils/swagger-defs.js
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,3 @@
 | 
				
			||||||
 | 
					'use strict';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export var methods = new Set(['get', 'put', 'post', 'delete', 'options', 'head', 'patch']);
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user