Skip to content

Commit

Permalink
Fix: Inputting beta version results in getting beta endpoint suggesti…
Browse files Browse the repository at this point in the history
…ons (#3289)
  • Loading branch information
ElinorW authored Sep 25, 2024
1 parent 53656fe commit 0ba6683
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/app/utils/open-api-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function parseOpenApiResponse(
params: IOpenApiParseContent
): IParsedOpenApiResponse {
const {
response: { paths },
response: { paths, info },
url
} = params;

Expand All @@ -29,8 +29,9 @@ export function parseOpenApiResponse(
});
});

const version = info?.version || '';
const createdAt = new Date().toISOString();
return { url, parameters, createdAt };
return { url, parameters, version, createdAt };
} catch (error: any) {
throw new Error(error);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ const AutoComplete = (props: IAutoCompleteProps) => {
const requestForAutocompleteOptions = (url: string, context: SignContext) => {
const signature = sanitizeQueryUrl(url);
const { requestUrl, queryVersion } = parseSampleUrl(signature);
const urlExistsInStore = autoCompleteOptions && requestUrl === autoCompleteOptions.url;
const urlExistsInStore = autoCompleteOptions && requestUrl === autoCompleteOptions.url &&
queryVersion === autoCompleteOptions.version;
if (urlExistsInStore) {
displayAutoCompleteSuggestions(autoCompleteOptions.url);
return;
Expand Down
1 change: 1 addition & 0 deletions src/modules/suggestions/cache-provider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ describe('Cache provider should', () => {
links: []
}
],
version: 'v1',
createdAt: '2020-04-01T00:00:00.000Z'
}

Expand Down
1 change: 1 addition & 0 deletions src/modules/suggestions/suggestions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class Suggestions implements ISuggestions {
private createOpenApiResponse(versionedResources: IResource[], url: string): IParsedOpenApiResponse {
const response: IParsedOpenApiResponse = {
createdAt: '',
version: '',
parameters: [{
verb: 'get',
values: [],
Expand Down
21 changes: 21 additions & 0 deletions src/types/open-api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
export interface IOpenApiResponse {
paths: any;
info: IOpenApiInfo;
}

export interface IOpenApiInfo {
version: string;
title: string;
description?: string;
termsOfService?: string;
contact?: IOpenApiContact;
license?: IOpenApiLicense;
}

export interface IOpenApiContact {
name: string;
url: string;
email: string;
}

export interface IOpenApiLicense {
name: string;
url: string;
}
export interface IOpenApiParseContent {
response: IOpenApiResponse;
url: string;
Expand All @@ -10,6 +30,7 @@ export interface IOpenApiParseContent {
export interface IParsedOpenApiResponse {
url: string;
parameters: IParameters[];
version: string;
createdAt: string;
}

Expand Down

0 comments on commit 0ba6683

Please sign in to comment.