Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OpenAPI] Fix fleet filepath API parameter #199538

Merged
merged 5 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion oas_docs/bundle.json
Original file line number Diff line number Diff line change
Expand Up @@ -21335,7 +21335,7 @@
]
}
},
"/api/fleet/epm/packages/{pkgName}/{pkgVersion}/{filePath*}": {
"/api/fleet/epm/packages/{pkgName}/{pkgVersion}/{filePath}": {
"get": {
"operationId": "get-fleet-epm-packages-pkgname-pkgversion-filepath",
"parameters": [
Expand Down
2 changes: 1 addition & 1 deletion oas_docs/bundle.serverless.json
Original file line number Diff line number Diff line change
Expand Up @@ -21335,7 +21335,7 @@
]
}
},
"/api/fleet/epm/packages/{pkgName}/{pkgVersion}/{filePath*}": {
"/api/fleet/epm/packages/{pkgName}/{pkgVersion}/{filePath}": {
"get": {
"operationId": "get-fleet-epm-packages-pkgname-pkgversion-filepath",
"parameters": [
Expand Down
2 changes: 1 addition & 1 deletion oas_docs/output/kibana.serverless.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19323,7 +19323,7 @@ paths:
tags:
- Elastic Package Manager (EPM)
x-beta: true
/api/fleet/epm/packages/{pkgName}/{pkgVersion}/{filePath*}:
/api/fleet/epm/packages/{pkgName}/{pkgVersion}/{filePath}:
get:
operationId: get-fleet-epm-packages-pkgname-pkgversion-filepath
parameters:
Expand Down
2 changes: 1 addition & 1 deletion oas_docs/output/kibana.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22127,7 +22127,7 @@ paths:
summary: Update package settings
tags:
- Elastic Package Manager (EPM)
/api/fleet/epm/packages/{pkgName}/{pkgVersion}/{filePath*}:
/api/fleet/epm/packages/{pkgName}/{pkgVersion}/{filePath}:
get:
operationId: get-fleet-epm-packages-pkgname-pkgversion-filepath
parameters:
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export const sharedOas = {
tags: ['versioned'],
},
},
'/foo/{id}/{path*}': {
'/foo/{id}/{path}': {
get: {
description: 'route description',
operationId: 'get-foo-id-path',
Expand Down
14 changes: 7 additions & 7 deletions packages/kbn-router-to-openapispec/src/generate_oas.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,9 @@ describe('generateOpenApiDocument', () => {
}
);
// router paths
expect(result.paths['/1-1/{id}/{path*}']!.get!.tags).toEqual(['1', '2']);
expect(result.paths['/1-2/{id}/{path*}']!.get!.tags).toEqual(['1']);
expect(result.paths['/2-1/{id}/{path*}']!.get!.tags).toEqual([]);
expect(result.paths['/1-1/{id}/{path}']!.get!.tags).toEqual(['1', '2']);
expect(result.paths['/1-2/{id}/{path}']!.get!.tags).toEqual(['1']);
expect(result.paths['/2-1/{id}/{path}']!.get!.tags).toEqual([]);
// versioned router paths
expect(result.paths['/v1-1']!.get!.tags).toEqual(['v1']);
expect(result.paths['/v1-2']!.get!.tags).toEqual(['v2', 'v3']);
Expand Down Expand Up @@ -392,17 +392,17 @@ describe('generateOpenApiDocument', () => {
);

// router paths
expect(result.paths['/1-1/{id}/{path*}']!.get).toMatchObject({
expect(result.paths['/1-1/{id}/{path}']!.get).toMatchObject({
'x-state': 'Technical Preview',
});
expect(result.paths['/1-2/{id}/{path*}']!.get).toMatchObject({
expect(result.paths['/1-2/{id}/{path}']!.get).toMatchObject({
'x-state': 'Beta',
});

expect(result.paths['/1-3/{id}/{path*}']!.get).not.toMatchObject({
expect(result.paths['/1-3/{id}/{path}']!.get).not.toMatchObject({
'x-state': expect.any(String),
});
expect(result.paths['/2-1/{id}/{path*}']!.get).not.toMatchObject({
expect(result.paths['/2-1/{id}/{path}']!.get).not.toMatchObject({
'x-state': expect.any(String),
});

Expand Down
7 changes: 5 additions & 2 deletions packages/kbn-router-to-openapispec/src/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ import {
getPathParameters,
createOpIdGenerator,
GetOpId,
assignToPaths,
extractTags,
} from './util';
import { assignToPaths, extractTags } from './util';

describe('extractTags', () => {
test.each([
Expand Down Expand Up @@ -115,9 +116,11 @@ describe('assignToPaths', () => {
const paths = {};
assignToPaths(paths, '/foo', {});
assignToPaths(paths, '/bar/{id?}', {});
assignToPaths(paths, '/bar/file/{path*}', {});
expect(paths).toEqual({
'/foo': {},
'/bar/{id}': {},
'/bar/file/{path}': {},
});
});
});
Expand Down Expand Up @@ -320,7 +323,7 @@ describe('createOpIdGenerator', () => {
{
input: {
method: 'get',
path: '/api/my/resource/{path*}',
path: '/api/my/resource/{path}',
},
output: 'get-my-resource-path',
},
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-router-to-openapispec/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export const assignToPaths = (
path: string,
pathObject: OpenAPIV3.PathItemObject
): void => {
const pathName = path.replace('?', '');
const pathName = path.replace(/[\?\*]/, '');
paths[pathName] = { ...paths[pathName], ...pathObject };
};

Expand Down
Loading