Skip to content

Commit

Permalink
fix(tenant-management): make changes to api
Browse files Browse the repository at this point in the history
make chnages to api

GH-45
  • Loading branch information
Surbhi-sharma1 committed Sep 30, 2024
1 parent 395971b commit 6e1625d
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -289,28 +289,33 @@ export class TenantController {
@authorize({
permissions: ['*'],
})
@get(`tenant/keys`, {
@get('verify-key/{key}', {
security: OPERATION_SECURITY_SPEC,
responses: {
[STATUS_CODE.OK]: {
description: 'Array of Tenant keys',
description: 'Check if key exists for any Tenant',
content: {
[CONTENT_TYPE.JSON]: {
schema: {
type: 'array',
items: {
type: 'string',
type: 'object',
properties: {
exists: {
type: 'boolean',
},
},
},
},
},
},
},
})
async getTenantKeys(
@param.filter(Tenant) filter?: Filter<Tenant>,
): Promise<string[]> {
const tenants = await this.tenantRepository.find(filter);
return tenants.map((tenant: Tenant) => tenant.key);
async checkKeyExists(
@param.path.string('key') key: string,
): Promise<{exists: boolean}> {
const tenantKeyExists = await this.tenantRepository.findOne({
where: {key: key},
});

return {exists: !!tenantKeyExists};
}
}
101 changes: 50 additions & 51 deletions services/tenant-management-service/src/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1154,50 +1154,6 @@
"operationId": "PingController.ping"
}
},
"/tenant/keys": {
"get": {
"x-controller-name": "TenantController",
"x-operation-name": "getTenantKeys",
"tags": [
"TenantController"
],
"security": [
{
"HTTPBearer": []
}
],
"responses": {
"200": {
"description": "Array of Tenant keys",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
}
},
"description": "",
"parameters": [
{
"name": "filter",
"in": "query",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/tenants.Filter"
}
}
}
}
],
"operationId": "TenantController.getTenantKeys"
}
},
"/tenants/count": {
"get": {
"x-controller-name": "TenantController",
Expand Down Expand Up @@ -1407,7 +1363,7 @@
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/tenants.Filter1"
"$ref": "#/components/schemas/tenants.Filter"
}
}
}
Expand Down Expand Up @@ -1566,7 +1522,7 @@
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/tenants.Filter"
"$ref": "#/components/schemas/tenants.Filter1"
}
}
}
Expand All @@ -1575,6 +1531,49 @@
"operationId": "TenantController.find"
}
},
"/verify-key/{key}": {
"get": {
"x-controller-name": "TenantController",
"x-operation-name": "checkKeyExists",
"tags": [
"TenantController"
],
"security": [
{
"HTTPBearer": []
}
],
"responses": {
"200": {
"description": "Check if key exists for any Tenant",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"exists": {
"type": "boolean"
}
}
}
}
}
}
},
"description": "",
"parameters": [
{
"name": "key",
"in": "path",
"schema": {
"type": "string"
},
"required": true
}
],
"operationId": "TenantController.checkKeyExists"
}
},
"/webhook": {
"post": {
"x-controller-name": "WebhookController",
Expand Down Expand Up @@ -4451,11 +4450,6 @@
}
]
},
"where": {
"title": "tenants.WhereFilter",
"type": "object",
"additionalProperties": true
},
"fields": {
"oneOf": [
{
Expand Down Expand Up @@ -4585,6 +4579,11 @@
}
]
},
"where": {
"title": "tenants.WhereFilter",
"type": "object",
"additionalProperties": true
},
"fields": {
"oneOf": [
{
Expand Down

0 comments on commit 6e1625d

Please sign in to comment.