Skip to content

Commit

Permalink
docs: swagger document update (#67)
Browse files Browse the repository at this point in the history
* swagger document updated

---------------
Refs: #65 
Reviewed-By: Phil Schneider <[email protected]>
  • Loading branch information
AnuragNagpure authored Mar 25, 2024
1 parent e9817ff commit e0a4b2c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
18 changes: 9 additions & 9 deletions src/hub/PolicyHub.Service/Controllers/PolicyHubController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static RouteGroupBuilder MapPolicyHubApi(this RouteGroupBuilder group)
.Produces(StatusCodes.Status200OK, typeof(string), Constants.JsonContentType);

policyHub.MapGet("policy-types", (PolicyTypeId? type, UseCaseId? useCase, IPolicyHubBusinessLogic logic) => logic.GetPolicyTypes(type, useCase))
.WithSwaggerDescription("Gets the policy types",
.WithSwaggerDescription("Provides all current supported policy types incl. a policy description and useCase link.",
"Example: GET: api/policy-hub/policy-types",
"OPTIONAL: Type to filter the response",
"OPTIONAL: UseCase to filter the response")
Expand All @@ -57,24 +57,24 @@ public static RouteGroupBuilder MapPolicyHubApi(this RouteGroupBuilder group)
policyHub.MapGet("policy-content",
(UseCaseId? useCase,
PolicyTypeId type,
string credential,
OperatorId operatorId,
string policyName,
OperatorId operatorType,
string? value,
IPolicyHubBusinessLogic logic) => logic.GetPolicyContentWithFiltersAsync(useCase, type, credential, operatorId, value))
.WithSwaggerDescription("Gets the content for a specific policy type",
IPolicyHubBusinessLogic logic) => logic.GetPolicyContentWithFiltersAsync(useCase, type, policyName, operatorType, value))
.WithSwaggerDescription("Receive the policy template 'access' or 'usage' for a single policy rule based on the request parameters submitted by the user.",
"Example: GET: api/policy-hub/policy-content",
"OPTIONAL: The use case",
"Type of the policy to get the content for",
"Policy type for which the policy is supposed to get created. Possible values: 'Access' or 'Usage'",
"The technical key of the policy",
"The operator of the left and right operand",
"OPTIONAL: Value for dynamic or regex operands")
"Policy Rule operator. Possible values: 'Equals' or 'In'",
"OPTIONAL: Value to be used for the rightOperand")
.RequireAuthorization()
.WithDefaultResponses()
.Produces(StatusCodes.Status200OK, typeof(PolicyResponse), Constants.JsonContentType)
.Produces(StatusCodes.Status404NotFound, typeof(ErrorResponse), Constants.JsonContentType);

policyHub.MapPost("policy-content", ([FromBody] PolicyContentRequest requestData, IPolicyHubBusinessLogic logic) => logic.GetPolicyContentAsync(requestData))
.WithSwaggerDescription("Gets the content for a specific policy type",
.WithSwaggerDescription("Receive the policy template 'access' or 'usage' for multiple policy rule template based on the input request body.",
"Example: POST: api/policy-hub/policy-content",
"Request data with the configuration of the constraints")
.RequireAuthorization()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public async Task GetPolicyTypes_WithUseCaseFilter_ReturnsExpected()
public async Task GetPolicyContent_WithRegexWithIncorrectValue_ReturnsExpected()
{
// Act
var response = await _client.GetAsync($"{BaseUrl}/policy-content?type={PolicyTypeId.Access}&credential=BusinessPartnerNumber&operatorId={OperatorId.Equals}&value=notmatching").ConfigureAwait(false);
var response = await _client.GetAsync($"{BaseUrl}/policy-content?type={PolicyTypeId.Access}&policyName=BusinessPartnerNumber&operatorType={OperatorId.Equals}&value=notmatching").ConfigureAwait(false);

// Assert
response.Should().NotBeNull();
Expand All @@ -150,7 +150,7 @@ public async Task GetPolicyContent_WithRegexWithIncorrectValue_ReturnsExpected()
public async Task GetPolicyContent_WithRegexWithoutValue_ReturnsExpected()
{
// Act
var response = await _client.GetAsync($"{BaseUrl}/policy-content?type={PolicyTypeId.Access}&credential=BusinessPartnerNumber&operatorId={OperatorId.Equals}").ConfigureAwait(false);
var response = await _client.GetAsync($"{BaseUrl}/policy-content?type={PolicyTypeId.Access}&policyName=BusinessPartnerNumber&operatorType={OperatorId.Equals}").ConfigureAwait(false);

// Assert
response.Should().NotBeNull();
Expand All @@ -164,7 +164,7 @@ public async Task GetPolicyContent_WithRegexWithoutValue_ReturnsExpected()
public async Task GetPolicyContent_BpnWithValue_ReturnsExpected()
{
// Act
var response = await _client.GetAsync($"{BaseUrl}/policy-content?type={PolicyTypeId.Usage}&credential=BusinessPartnerNumber&operatorId={OperatorId.Equals}&value=BPNL00000003CRHK").ConfigureAwait(false);
var response = await _client.GetAsync($"{BaseUrl}/policy-content?type={PolicyTypeId.Usage}&policyName=BusinessPartnerNumber&operatorType={OperatorId.Equals}&value=BPNL00000003CRHK").ConfigureAwait(false);

// Assert
response.Should().NotBeNull();
Expand All @@ -178,7 +178,7 @@ public async Task GetPolicyContent_BpnWithValue_ReturnsExpected()
public async Task GetPolicyContent_UsageFrameworkEquals_ReturnsExpected()
{
// Act
var response = await _client.GetAsync($"{BaseUrl}/policy-content?type={PolicyTypeId.Usage}&credential=FrameworkAgreement.traceability&operatorId={OperatorId.Equals}").ConfigureAwait(false);
var response = await _client.GetAsync($"{BaseUrl}/policy-content?type={PolicyTypeId.Usage}&policyName=FrameworkAgreement.traceability&operatorType={OperatorId.Equals}").ConfigureAwait(false);

// Assert
response.Should().NotBeNull();
Expand All @@ -192,7 +192,7 @@ public async Task GetPolicyContent_UsageFrameworkEquals_ReturnsExpected()
public async Task GetPolicyContent_UsageDismantlerIn_ReturnsExpected()
{
// Act
var response = await _client.GetAsync($"{BaseUrl}/policy-content?type={PolicyTypeId.Usage}&credential=companyRole.dismantler&operatorId={OperatorId.In}").ConfigureAwait(false);
var response = await _client.GetAsync($"{BaseUrl}/policy-content?type={PolicyTypeId.Usage}&policyName=companyRole.dismantler&operatorType={OperatorId.In}").ConfigureAwait(false);

// Assert
response.Should().NotBeNull();
Expand All @@ -206,7 +206,7 @@ public async Task GetPolicyContent_UsageDismantlerIn_ReturnsExpected()
public async Task GetPolicyContent_TraceabilityUsagePurposeEquals_ReturnsExpected()
{
// Act
var response = await _client.GetAsync($"{BaseUrl}/policy-content?useCase={UseCaseId.Traceability}&type={PolicyTypeId.Usage}&credential=purpose.trace.v1.TraceBattery&operatorId={OperatorId.Equals}").ConfigureAwait(false);
var response = await _client.GetAsync($"{BaseUrl}/policy-content?useCase={UseCaseId.Traceability}&type={PolicyTypeId.Usage}&policyName=purpose.trace.v1.TraceBattery&operatorType={OperatorId.Equals}").ConfigureAwait(false);

// Assert
response.Should().NotBeNull();
Expand Down

0 comments on commit e0a4b2c

Please sign in to comment.