mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-28 19:43:43 +03:00
fix: prefix operation ids with parent id (#1245)
Co-authored-by: ben.blowers <ben.blowers@imanage.com> Co-authored-by: anastasiia-developer <anastasiia@redocly.com>
This commit is contained in:
parent
1e80dd69a3
commit
fd8917e5c1
|
@ -49,7 +49,7 @@ describe('Menu', () => {
|
||||||
cy.location('hash').should('equal', '#tag/pet');
|
cy.location('hash').should('equal', '#tag/pet');
|
||||||
|
|
||||||
cy.contains('[role=menuitem]', 'Find pet by ID').click({ force: true });
|
cy.contains('[role=menuitem]', 'Find pet by ID').click({ force: true });
|
||||||
cy.location('hash').should('equal', '#operation/getPetById');
|
cy.location('hash').should('equal', '#tag/pet/operation/getPetById');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should deactivate tag when other is activated', () => {
|
it('should deactivate tag when other is activated', () => {
|
||||||
|
|
|
@ -21,12 +21,12 @@ describe('Servers', () => {
|
||||||
initReDoc(win, spec, {});
|
initReDoc(win, spec, {});
|
||||||
|
|
||||||
// TODO add cy-data attributes
|
// TODO add cy-data attributes
|
||||||
cy.get('[data-section-id="operation/addPet"]').should(
|
cy.get('[data-section-id="tag/pet/operation/addPet"]').should(
|
||||||
'contain',
|
'contain',
|
||||||
'http://petstore.swagger.io/v2/pet',
|
'http://petstore.swagger.io/v2/pet',
|
||||||
);
|
);
|
||||||
|
|
||||||
cy.get('[data-section-id="operation/addPet"]').should(
|
cy.get('[data-section-id="tag/pet/operation/addPet"]').should(
|
||||||
'contain',
|
'contain',
|
||||||
'http://petstore.swagger.io/sandbox/pet',
|
'http://petstore.swagger.io/sandbox/pet',
|
||||||
);
|
);
|
||||||
|
@ -40,7 +40,7 @@ describe('Servers', () => {
|
||||||
initReDoc(win, spec, {});
|
initReDoc(win, spec, {});
|
||||||
|
|
||||||
// TODO add cy-data attributes
|
// TODO add cy-data attributes
|
||||||
cy.get('[data-section-id="operation/addPet"]').should(
|
cy.get('[data-section-id="tag/pet/operation/addPet"]').should(
|
||||||
'contain',
|
'contain',
|
||||||
'http://localhost:' + win.location.port + '/pet',
|
'http://localhost:' + win.location.port + '/pet',
|
||||||
);
|
);
|
||||||
|
@ -55,7 +55,7 @@ describe('Servers', () => {
|
||||||
initReDoc(win, spec, {});
|
initReDoc(win, spec, {});
|
||||||
|
|
||||||
// TODO add cy-data attributes
|
// TODO add cy-data attributes
|
||||||
cy.get('[data-section-id="operation/addPet"]').should(
|
cy.get('[data-section-id="tag/pet/operation/addPet"]').should(
|
||||||
'contain',
|
'contain',
|
||||||
'http://localhost:' + win.location.port + '/pet',
|
'http://localhost:' + win.location.port + '/pet',
|
||||||
);
|
);
|
||||||
|
|
19
e2e/integration/urls.e2e.ts
Normal file
19
e2e/integration/urls.e2e.ts
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
describe('Supporting both operation/* and parent/*/operation* urls', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.visit('e2e/standalone.html');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should supporting operation/* url', () => {
|
||||||
|
cy.url().then(loc => {
|
||||||
|
cy.visit(loc + '#operation/updatePet');
|
||||||
|
cy.get('li[data-item-id="tag/pet/operation/updatePet"]').should('be.visible');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should supporting parent/*/operation url', () => {
|
||||||
|
cy.url().then(loc => {
|
||||||
|
cy.visit(loc + '#tag/pet/operation/addPet');
|
||||||
|
cy.get('li[data-item-id="tag/pet/operation/addPet"]').should('be.visible');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -17,6 +17,7 @@ import { RequestSamples } from '../RequestSamples/RequestSamples';
|
||||||
import { ResponsesList } from '../Responses/ResponsesList';
|
import { ResponsesList } from '../Responses/ResponsesList';
|
||||||
import { ResponseSamples } from '../ResponseSamples/ResponseSamples';
|
import { ResponseSamples } from '../ResponseSamples/ResponseSamples';
|
||||||
import { SecurityRequirements } from '../SecurityRequirement/SecurityRequirement';
|
import { SecurityRequirements } from '../SecurityRequirement/SecurityRequirement';
|
||||||
|
import { SECTION_ATTR } from '../../services';
|
||||||
|
|
||||||
const Description = styled.div`
|
const Description = styled.div`
|
||||||
margin-bottom: ${({ theme }) => theme.spacing.unit * 6}px;
|
margin-bottom: ${({ theme }) => theme.spacing.unit * 6}px;
|
||||||
|
@ -37,7 +38,7 @@ export class Operation extends React.Component<OperationProps> {
|
||||||
return (
|
return (
|
||||||
<OptionsContext.Consumer>
|
<OptionsContext.Consumer>
|
||||||
{options => (
|
{options => (
|
||||||
<Row>
|
<Row {...{ [SECTION_ATTR]: operation.operationHash }} id={operation.operationHash}>
|
||||||
<MiddlePanel>
|
<MiddlePanel>
|
||||||
<H2>
|
<H2>
|
||||||
<ShareLink to={operation.id} />
|
<ShareLink to={operation.id} />
|
||||||
|
|
|
@ -70,6 +70,7 @@ export class OperationModel implements IMenuItem {
|
||||||
|
|
||||||
pointer: string;
|
pointer: string;
|
||||||
operationId?: string;
|
operationId?: string;
|
||||||
|
operationHash?: string;
|
||||||
httpVerb: string;
|
httpVerb: string;
|
||||||
deprecated: boolean;
|
deprecated: boolean;
|
||||||
path: string;
|
path: string;
|
||||||
|
@ -123,9 +124,10 @@ export class OperationModel implements IMenuItem {
|
||||||
// TODO: update getting pathInfo for overriding servers on path level
|
// TODO: update getting pathInfo for overriding servers on path level
|
||||||
this.servers = normalizeServers('', operationSpec.servers || operationSpec.pathServers || []);
|
this.servers = normalizeServers('', operationSpec.servers || operationSpec.pathServers || []);
|
||||||
} else {
|
} else {
|
||||||
|
this.operationHash = operationSpec.operationId && 'operation/' + operationSpec.operationId
|
||||||
this.id =
|
this.id =
|
||||||
operationSpec.operationId !== undefined
|
operationSpec.operationId !== undefined
|
||||||
? 'operation/' + operationSpec.operationId
|
? (parent ? parent.id + '/' : '') + this.operationHash
|
||||||
: parent !== undefined
|
: parent !== undefined
|
||||||
? parent.id + this.pointer
|
? parent.id + this.pointer
|
||||||
: this.pointer;
|
: this.pointer;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user