Skip to content

Commit

Permalink
[HTTP/OAS] Add descriptions for role management APIs (#184265)
Browse files Browse the repository at this point in the history
Co-authored-by: Aleh Zasypkin <aleh.zasypkin@elastic.co>
  • Loading branch information
lcawl and azasypkin authored May 30, 2024
1 parent 123cbca commit dfbfe05
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export function defineDeleteRolesRoutes({ router }: RouteDefinitionParams) {
router.delete(
{
path: '/api/security/role/{name}',
options: {
description: `Delete a role`,
},
validate: {
params: schema.object({ name: schema.string({ minLength: 1 }) }),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ export function defineGetRolesRoutes({
router.get(
{
path: '/api/security/role/{name}',
options: {
description: `Get a role`,
},
validate: {
params: schema.object({ name: schema.string({ minLength: 1 }) }),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ export function defineGetAllRolesRoutes({
config,
}: RouteDefinitionParams) {
router.get(
{ path: '/api/security/role', validate: false },
{
path: '/api/security/role',
options: {
description: `Get all roles`,
},
validate: false,
},
createLicensedRouteHandler(async (context, request, response) => {
try {
const hideReservedRoles = buildFlavor === 'serverless';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ export function definePutRolesRoutes({
router.put(
{
path: '/api/security/role/{name}',
options: {
description: `Create or update a role`,
},
validate: {
params: schema.object({ name: schema.string({ minLength: 1, maxLength: 1024 }) }),
query: schema.object({ createOnly: schema.boolean({ defaultValue: false }) }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ describe('Invalidate sessions routes', () => {
});

it('correctly defines route.', () => {
expect(routeConfig.options).toEqual({ tags: ['access:sessionManagement'] });
expect(routeConfig.options).toEqual({
description: 'Invalidate user sessions',
tags: ['access:sessionManagement'],
});

const bodySchema = (routeConfig.validate as any).body as ObjectType;
expect(() => bodySchema.validate({})).toThrowErrorMatchingInlineSnapshot(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ export function defineInvalidateSessionsRoutes({ router, getSession }: RouteDefi
),
}),
},
options: { tags: ['access:sessionManagement'] },
options: {
tags: ['access:sessionManagement'],
description: `Invalidate user sessions`,
},
},
async (_context, request, response) => {
return response.ok({
Expand Down

0 comments on commit dfbfe05

Please sign in to comment.