mirror of
				https://github.com/Redocly/redoc.git
				synced 2025-11-04 01:37:32 +03:00 
			
		
		
		
	fix: use operation path if operation summary/description is not provided (#1596)
resolves #1270
This commit is contained in:
		
							parent
							
								
									d7a0a4da17
								
							
						
					
					
						commit
						4b072be8d1
					
				| 
						 | 
					@ -101,6 +101,13 @@ describe('Utils', () => {
 | 
				
			||||||
      expect(getOperationSummary(operation as any).length).toBe(50);
 | 
					      expect(getOperationSummary(operation as any).length).toBe(50);
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    it('Should return pathName if no summary, operationId, description', () => {
 | 
				
			||||||
 | 
					      const operation = {
 | 
				
			||||||
 | 
					        pathName: '/sandbox/test'
 | 
				
			||||||
 | 
					      };
 | 
				
			||||||
 | 
					      expect(getOperationSummary(operation as any)).toBe('/sandbox/test');
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    it('Should return <no summary> if no info', () => {
 | 
					    it('Should return <no summary> if no info', () => {
 | 
				
			||||||
      const operation = {
 | 
					      const operation = {
 | 
				
			||||||
        description: undefined,
 | 
					        description: undefined,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,12 +1,12 @@
 | 
				
			||||||
import { dirname } from 'path';
 | 
					import { dirname } from 'path';
 | 
				
			||||||
import * as URLtemplate from 'url-template';
 | 
					import * as URLtemplate from 'url-template';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import { ExtendedOpenAPIOperation } from '../services';
 | 
				
			||||||
import { FieldModel } from '../services/models';
 | 
					import { FieldModel } from '../services/models';
 | 
				
			||||||
import { OpenAPIParser } from '../services/OpenAPIParser';
 | 
					import { OpenAPIParser } from '../services/OpenAPIParser';
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
  OpenAPIEncoding,
 | 
					  OpenAPIEncoding,
 | 
				
			||||||
  OpenAPIMediaType,
 | 
					  OpenAPIMediaType,
 | 
				
			||||||
  OpenAPIOperation,
 | 
					 | 
				
			||||||
  OpenAPIParameter,
 | 
					  OpenAPIParameter,
 | 
				
			||||||
  OpenAPIParameterStyle,
 | 
					  OpenAPIParameterStyle,
 | 
				
			||||||
  OpenAPISchema,
 | 
					  OpenAPISchema,
 | 
				
			||||||
| 
						 | 
					@ -62,12 +62,13 @@ export function isOperationName(key: string): boolean {
 | 
				
			||||||
  return key in operationNames;
 | 
					  return key in operationNames;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function getOperationSummary(operation: OpenAPIOperation): string {
 | 
					export function getOperationSummary(operation: ExtendedOpenAPIOperation): string {
 | 
				
			||||||
  return (
 | 
					  return (
 | 
				
			||||||
    operation.summary ||
 | 
					    operation.summary ||
 | 
				
			||||||
    operation.operationId ||
 | 
					    operation.operationId ||
 | 
				
			||||||
    (operation.description && operation.description.substring(0, 50)) ||
 | 
					    (operation.description && operation.description.substring(0, 50)) ||
 | 
				
			||||||
    '<no summary>'
 | 
					    operation.pathName ||
 | 
				
			||||||
 | 
					   '<no summary>'
 | 
				
			||||||
  );
 | 
					  );
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user