From a3c9d6f121e49b4f02999229b51e4fd1d4772bbc Mon Sep 17 00:00:00 2001 From: Phil Schneider Date: Wed, 2 Oct 2024 10:46:10 +0200 Subject: [PATCH] feat(api-hub): create open api spec on build (#209) Refs: #207 Reviewed-By: Evelyn Gurschler Reviewed-By: Norbert Truchsess --- .tractusx | 2 + DEPENDENCIES | 8 +- docs/api/hub-service.yaml | 1819 +++++++++++++++++ .../release-process/Release Process.md | 30 +- .../PolicyHub.DbAccess.csproj | 4 +- .../PolicyHub.Migrations.csproj | 4 +- .../.config/dotnet-tools.json | 13 + .../PolicyHub.Service.csproj | 8 +- src/hub/PolicyHub.Service/Program.cs | 5 +- .../Controllers/PolicyHubControllerTests.cs | 15 - .../Setup/IntegrationTestFactory.cs | 10 +- .../appsettings.IntegrationTests.json | 39 - 12 files changed, 1879 insertions(+), 78 deletions(-) create mode 100644 docs/api/hub-service.yaml create mode 100644 src/hub/PolicyHub.Service/.config/dotnet-tools.json delete mode 100644 tests/hub/PolicyHub.Service.Tests/appsettings.IntegrationTests.json diff --git a/.tractusx b/.tractusx index d1deea02..57c78577 100644 --- a/.tractusx +++ b/.tractusx @@ -19,3 +19,5 @@ product: "Policy Hub" leadingRepository: "https://github.com/eclipse-tractusx/policy-hub" +openApiSpecs: +- "https://raw.githubusercontent.com/eclipse-tractusx/policy-hub/refs/heads/main/docs/api/hub-service.yaml" diff --git a/DEPENDENCIES b/DEPENDENCIES index 722ad4d1..c4a6be15 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -32,10 +32,10 @@ nuget/nuget/-/Serilog.Sinks.File/5.0.0, Apache-2.0, approved, #11116 nuget/nuget/-/Serilog/3.1.1, Apache-2.0, approved, #13978 nuget/nuget/-/SharpZipLib/1.4.2, MIT AND GFDL-1.3-or-later AND (Apache-2.0 AND MIT) AND WTFPL AND bzip2-1.0.6 AND LicenseRef-Permissive-license-with-conditions AND LicenseRef-Permission-Notice, approved, #10058 nuget/nuget/-/SshNet.Security.Cryptography/1.3.0, MIT, approved, clearlydefined -nuget/nuget/-/Swashbuckle.AspNetCore.Swagger/6.5.0, MIT AND Apache-2.0, approved, #7160 -nuget/nuget/-/Swashbuckle.AspNetCore.SwaggerGen/6.5.0, MIT AND Apache-2.0, approved, #7156 -nuget/nuget/-/Swashbuckle.AspNetCore.SwaggerUI/6.5.0, MIT AND Apache-2.0, approved, #7158 -nuget/nuget/-/Swashbuckle.AspNetCore/6.5.0, MIT AND Apache-2.0, approved, #7159 +nuget/nuget/-/Swashbuckle.AspNetCore.Swagger/6.8.0, MIT AND Apache-2.0, approved, #16262 +nuget/nuget/-/Swashbuckle.AspNetCore.SwaggerGen/6.8.0, MIT AND Apache-2.0, approved, #16259 +nuget/nuget/-/Swashbuckle.AspNetCore.SwaggerUI/6.8.0, MIT AND Apache-2.0, approved, #16261 +nuget/nuget/-/Swashbuckle.AspNetCore/6.8.0, MIT AND Apache-2.0, approved, #16260 nuget/nuget/-/Testcontainers.PostgreSql/3.7.0, MIT, approved, #13960 nuget/nuget/-/Testcontainers/3.7.0, MIT, approved, #13982 nuget/nuget/-/Xunit.Extensions.AssemblyFixture/2.4.1, MIT, approved, #3502 diff --git a/docs/api/hub-service.yaml b/docs/api/hub-service.yaml new file mode 100644 index 00000000..7686fc35 --- /dev/null +++ b/docs/api/hub-service.yaml @@ -0,0 +1,1819 @@ +openapi: 3.0.1 +info: + title: Org.Eclipse.TractusX.PolicyHub.Service + version: v1.1.0 +paths: + /api/policy-hub/policy-attributes: + get: + tags: + - 'Org.Eclipse.TractusX.PolicyHub.Service, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null' + summary: Gets the keys for the attributes + description: 'Example: GET: api/policy-hub/policy-attributes' + responses: + '200': + description: OK + content: + application/json: + schema: + type: string + '401': + description: Unauthorized + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '500': + description: Internal Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + /api/policy-hub/policy-types: + get: + tags: + - 'Org.Eclipse.TractusX.PolicyHub.Service, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null' + summary: Provides all current supported policy types incl. a policy description and useCase link. + description: 'Example: GET: api/policy-hub/policy-types' + parameters: + - name: type + in: query + schema: + $ref: '#/components/schemas/PolicyTypeId' + - name: useCase + in: query + schema: + $ref: '#/components/schemas/UseCaseId' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/PolicyTypeResponse' + '401': + description: Unauthorized + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '500': + description: Internal Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + /api/policy-hub/policy-content: + get: + tags: + - 'Org.Eclipse.TractusX.PolicyHub.Service, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null' + summary: Receive the policy template 'access' or 'usage' for a single policy rule based on the request parameters submitted by the user. + description: 'Example: GET: api/policy-hub/policy-content' + parameters: + - name: useCase + in: query + schema: + $ref: '#/components/schemas/UseCaseId' + - name: type + in: query + required: true + schema: + $ref: '#/components/schemas/PolicyTypeId' + - name: policyName + in: query + required: true + schema: + type: string + - name: operatorType + in: query + required: true + schema: + $ref: '#/components/schemas/OperatorId' + - name: value + in: query + schema: + type: string + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/PolicyResponse' + '401': + description: Unauthorized + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '500': + description: Internal Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '400': + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '404': + description: Not Found + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + post: + tags: + - 'Org.Eclipse.TractusX.PolicyHub.Service, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null' + summary: Receive the policy template 'access' or 'usage' for multiple policy rule template based on the input request body. + description: 'Example: POST: api/policy-hub/policy-content' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/PolicyContentRequest' + required: true + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/PolicyResponse' + '401': + description: Unauthorized + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '500': + description: Internal Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '400': + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse' + '404': + description: Not Found + content: + application/json: + schema: + $ref: '#/components/schemas/ControllerArgumentException' +components: + schemas: + AdditionalAttributes: + type: object + properties: + key: + type: string + possibleValues: + type: array + items: + type: string + additionalProperties: false + Assembly: + type: object + properties: + definedTypes: + type: array + items: + $ref: '#/components/schemas/TypeInfo' + readOnly: true + exportedTypes: + type: array + items: + $ref: '#/components/schemas/Type' + readOnly: true + codeBase: + type: string + nullable: true + readOnly: true + deprecated: true + entryPoint: + $ref: '#/components/schemas/MethodInfo' + fullName: + type: string + nullable: true + readOnly: true + imageRuntimeVersion: + type: string + readOnly: true + isDynamic: + type: boolean + readOnly: true + location: + type: string + readOnly: true + reflectionOnly: + type: boolean + readOnly: true + isCollectible: + type: boolean + readOnly: true + isFullyTrusted: + type: boolean + readOnly: true + customAttributes: + type: array + items: + $ref: '#/components/schemas/CustomAttributeData' + readOnly: true + escapedCodeBase: + type: string + readOnly: true + deprecated: true + manifestModule: + $ref: '#/components/schemas/Module' + modules: + type: array + items: + $ref: '#/components/schemas/Module' + readOnly: true + globalAssemblyCache: + type: boolean + readOnly: true + deprecated: true + hostContext: + type: integer + format: int64 + readOnly: true + securityRuleSet: + $ref: '#/components/schemas/SecurityRuleSet' + additionalProperties: false + AttributeKeyId: + enum: + - Regex + - Static + - DynamicValue + - Brands + - Version + type: string + CallingConventions: + enum: + - Standard + - VarArgs + - Any + - HasThis + - ExplicitThis + type: string + Constraint: + type: object + properties: + odrl:and: + type: array + items: + $ref: '#/components/schemas/Constraint' + nullable: true + odrl:or: + type: array + items: + $ref: '#/components/schemas/Constraint' + nullable: true + leftOperand: + type: string + nullable: true + operator: + type: string + nullable: true + rightOperand: + nullable: true + additionalProperties: false + ConstraintOperandId: + enum: + - And + - Or + type: string + Constraints: + type: object + properties: + key: + type: string + operator: + $ref: '#/components/schemas/OperatorId' + value: + type: string + nullable: true + additionalProperties: false + ConstructorInfo: + type: object + properties: + name: + type: string + readOnly: true + declaringType: + $ref: '#/components/schemas/Type' + reflectedType: + $ref: '#/components/schemas/Type' + module: + $ref: '#/components/schemas/Module' + customAttributes: + type: array + items: + $ref: '#/components/schemas/CustomAttributeData' + readOnly: true + isCollectible: + type: boolean + readOnly: true + metadataToken: + type: integer + format: int32 + readOnly: true + attributes: + $ref: '#/components/schemas/MethodAttributes' + methodImplementationFlags: + $ref: '#/components/schemas/MethodImplAttributes' + callingConvention: + $ref: '#/components/schemas/CallingConventions' + isAbstract: + type: boolean + readOnly: true + isConstructor: + type: boolean + readOnly: true + isFinal: + type: boolean + readOnly: true + isHideBySig: + type: boolean + readOnly: true + isSpecialName: + type: boolean + readOnly: true + isStatic: + type: boolean + readOnly: true + isVirtual: + type: boolean + readOnly: true + isAssembly: + type: boolean + readOnly: true + isFamily: + type: boolean + readOnly: true + isFamilyAndAssembly: + type: boolean + readOnly: true + isFamilyOrAssembly: + type: boolean + readOnly: true + isPrivate: + type: boolean + readOnly: true + isPublic: + type: boolean + readOnly: true + isConstructedGenericMethod: + type: boolean + readOnly: true + isGenericMethod: + type: boolean + readOnly: true + isGenericMethodDefinition: + type: boolean + readOnly: true + containsGenericParameters: + type: boolean + readOnly: true + methodHandle: + $ref: '#/components/schemas/RuntimeMethodHandle' + isSecurityCritical: + type: boolean + readOnly: true + isSecuritySafeCritical: + type: boolean + readOnly: true + isSecurityTransparent: + type: boolean + readOnly: true + memberType: + $ref: '#/components/schemas/MemberTypes' + additionalProperties: false + ControllerArgumentException: + type: object + properties: + targetSite: + $ref: '#/components/schemas/MethodBase' + message: + type: string + readOnly: true + data: + type: object + additionalProperties: { } + readOnly: true + innerException: + $ref: '#/components/schemas/Exception' + helpLink: + type: string + nullable: true + source: + type: string + nullable: true + hResult: + type: integer + format: int32 + stackTrace: + type: string + nullable: true + readOnly: true + errorType: + $ref: '#/components/schemas/Type' + errorCode: + type: integer + format: int32 + readOnly: true + parameters: + type: array + items: + $ref: '#/components/schemas/ErrorParameter' + readOnly: true + hasDetails: + type: boolean + readOnly: true + paramName: + type: string + nullable: true + readOnly: true + additionalProperties: false + CustomAttributeData: + type: object + properties: + attributeType: + $ref: '#/components/schemas/Type' + constructor: + $ref: '#/components/schemas/ConstructorInfo' + constructorArguments: + type: array + items: + $ref: '#/components/schemas/CustomAttributeTypedArgument' + readOnly: true + namedArguments: + type: array + items: + $ref: '#/components/schemas/CustomAttributeNamedArgument' + readOnly: true + additionalProperties: false + CustomAttributeNamedArgument: + type: object + properties: + memberInfo: + $ref: '#/components/schemas/MemberInfo' + typedValue: + $ref: '#/components/schemas/CustomAttributeTypedArgument' + memberName: + type: string + readOnly: true + isField: + type: boolean + readOnly: true + additionalProperties: false + CustomAttributeTypedArgument: + type: object + properties: + argumentType: + $ref: '#/components/schemas/Type' + value: + nullable: true + additionalProperties: false + ErrorDetails: + type: object + properties: + errorCode: + type: string + type: + type: string + message: + type: string + parameters: + type: array + items: + $ref: '#/components/schemas/ErrorParameter' + additionalProperties: false + ErrorParameter: + type: object + properties: + name: + type: string + value: + type: string + additionalProperties: false + ErrorResponse: + type: object + properties: + type: + type: string + title: + type: string + status: + type: integer + format: int32 + errors: + type: object + additionalProperties: + type: array + items: + type: string + errorId: + type: string + details: + type: array + items: + $ref: '#/components/schemas/ErrorDetails' + nullable: true + additionalProperties: false + EventAttributes: + enum: + - None + - SpecialName + - RTSpecialName + type: string + EventInfo: + type: object + properties: + name: + type: string + readOnly: true + declaringType: + $ref: '#/components/schemas/Type' + reflectedType: + $ref: '#/components/schemas/Type' + module: + $ref: '#/components/schemas/Module' + customAttributes: + type: array + items: + $ref: '#/components/schemas/CustomAttributeData' + readOnly: true + isCollectible: + type: boolean + readOnly: true + metadataToken: + type: integer + format: int32 + readOnly: true + memberType: + $ref: '#/components/schemas/MemberTypes' + attributes: + $ref: '#/components/schemas/EventAttributes' + isSpecialName: + type: boolean + readOnly: true + addMethod: + $ref: '#/components/schemas/MethodInfo' + removeMethod: + $ref: '#/components/schemas/MethodInfo' + raiseMethod: + $ref: '#/components/schemas/MethodInfo' + isMulticast: + type: boolean + readOnly: true + eventHandlerType: + $ref: '#/components/schemas/Type' + additionalProperties: false + Exception: + type: object + properties: + targetSite: + $ref: '#/components/schemas/MethodBase' + message: + type: string + readOnly: true + data: + type: object + additionalProperties: { } + readOnly: true + innerException: + $ref: '#/components/schemas/Exception' + helpLink: + type: string + nullable: true + source: + type: string + nullable: true + hResult: + type: integer + format: int32 + stackTrace: + type: string + nullable: true + readOnly: true + additionalProperties: false + FieldAttributes: + enum: + - PrivateScope + - Private + - FamANDAssem + - Assembly + - Family + - FamORAssem + - Public + - FieldAccessMask + - Static + - InitOnly + - Literal + - NotSerialized + - HasFieldRVA + - SpecialName + - RTSpecialName + - HasFieldMarshal + - PinvokeImpl + - HasDefault + - ReservedMask + type: string + FieldInfo: + type: object + properties: + name: + type: string + readOnly: true + declaringType: + $ref: '#/components/schemas/Type' + reflectedType: + $ref: '#/components/schemas/Type' + module: + $ref: '#/components/schemas/Module' + customAttributes: + type: array + items: + $ref: '#/components/schemas/CustomAttributeData' + readOnly: true + isCollectible: + type: boolean + readOnly: true + metadataToken: + type: integer + format: int32 + readOnly: true + memberType: + $ref: '#/components/schemas/MemberTypes' + attributes: + $ref: '#/components/schemas/FieldAttributes' + fieldType: + $ref: '#/components/schemas/Type' + isInitOnly: + type: boolean + readOnly: true + isLiteral: + type: boolean + readOnly: true + isNotSerialized: + type: boolean + readOnly: true + deprecated: true + isPinvokeImpl: + type: boolean + readOnly: true + isSpecialName: + type: boolean + readOnly: true + isStatic: + type: boolean + readOnly: true + isAssembly: + type: boolean + readOnly: true + isFamily: + type: boolean + readOnly: true + isFamilyAndAssembly: + type: boolean + readOnly: true + isFamilyOrAssembly: + type: boolean + readOnly: true + isPrivate: + type: boolean + readOnly: true + isPublic: + type: boolean + readOnly: true + isSecurityCritical: + type: boolean + readOnly: true + isSecuritySafeCritical: + type: boolean + readOnly: true + isSecurityTransparent: + type: boolean + readOnly: true + fieldHandle: + $ref: '#/components/schemas/RuntimeFieldHandle' + additionalProperties: false + GenericParameterAttributes: + enum: + - None + - Covariant + - Contravariant + - VarianceMask + - ReferenceTypeConstraint + - NotNullableValueTypeConstraint + - DefaultConstructorConstraint + - SpecialConstraintMask + type: string + ICustomAttributeProvider: + type: object + additionalProperties: false + IntPtr: + type: object + additionalProperties: false + LayoutKind: + enum: + - Sequential + - Explicit + - Auto + type: string + MemberInfo: + type: object + properties: + memberType: + $ref: '#/components/schemas/MemberTypes' + name: + type: string + readOnly: true + declaringType: + $ref: '#/components/schemas/Type' + reflectedType: + $ref: '#/components/schemas/Type' + module: + $ref: '#/components/schemas/Module' + customAttributes: + type: array + items: + $ref: '#/components/schemas/CustomAttributeData' + readOnly: true + isCollectible: + type: boolean + readOnly: true + metadataToken: + type: integer + format: int32 + readOnly: true + additionalProperties: false + MemberTypes: + enum: + - Constructor + - Event + - Field + - Method + - Property + - TypeInfo + - Custom + - NestedType + - All + type: string + MethodAttributes: + enum: + - PrivateScope + - Private + - FamANDAssem + - Assembly + - Family + - FamORAssem + - Public + - MemberAccessMask + - UnmanagedExport + - Static + - Final + - Virtual + - HideBySig + - NewSlot + - CheckAccessOnOverride + - Abstract + - SpecialName + - RTSpecialName + - PinvokeImpl + - HasSecurity + - RequireSecObject + - ReservedMask + type: string + MethodBase: + type: object + properties: + memberType: + $ref: '#/components/schemas/MemberTypes' + name: + type: string + readOnly: true + declaringType: + $ref: '#/components/schemas/Type' + reflectedType: + $ref: '#/components/schemas/Type' + module: + $ref: '#/components/schemas/Module' + customAttributes: + type: array + items: + $ref: '#/components/schemas/CustomAttributeData' + readOnly: true + isCollectible: + type: boolean + readOnly: true + metadataToken: + type: integer + format: int32 + readOnly: true + attributes: + $ref: '#/components/schemas/MethodAttributes' + methodImplementationFlags: + $ref: '#/components/schemas/MethodImplAttributes' + callingConvention: + $ref: '#/components/schemas/CallingConventions' + isAbstract: + type: boolean + readOnly: true + isConstructor: + type: boolean + readOnly: true + isFinal: + type: boolean + readOnly: true + isHideBySig: + type: boolean + readOnly: true + isSpecialName: + type: boolean + readOnly: true + isStatic: + type: boolean + readOnly: true + isVirtual: + type: boolean + readOnly: true + isAssembly: + type: boolean + readOnly: true + isFamily: + type: boolean + readOnly: true + isFamilyAndAssembly: + type: boolean + readOnly: true + isFamilyOrAssembly: + type: boolean + readOnly: true + isPrivate: + type: boolean + readOnly: true + isPublic: + type: boolean + readOnly: true + isConstructedGenericMethod: + type: boolean + readOnly: true + isGenericMethod: + type: boolean + readOnly: true + isGenericMethodDefinition: + type: boolean + readOnly: true + containsGenericParameters: + type: boolean + readOnly: true + methodHandle: + $ref: '#/components/schemas/RuntimeMethodHandle' + isSecurityCritical: + type: boolean + readOnly: true + isSecuritySafeCritical: + type: boolean + readOnly: true + isSecurityTransparent: + type: boolean + readOnly: true + additionalProperties: false + MethodImplAttributes: + enum: + - IL + - Native + - OPTIL + - CodeTypeMask + - ManagedMask + - NoInlining + - ForwardRef + - Synchronized + - NoOptimization + - PreserveSig + - AggressiveInlining + - AggressiveOptimization + - InternalCall + - MaxMethodImplVal + type: string + MethodInfo: + type: object + properties: + name: + type: string + readOnly: true + declaringType: + $ref: '#/components/schemas/Type' + reflectedType: + $ref: '#/components/schemas/Type' + module: + $ref: '#/components/schemas/Module' + customAttributes: + type: array + items: + $ref: '#/components/schemas/CustomAttributeData' + readOnly: true + isCollectible: + type: boolean + readOnly: true + metadataToken: + type: integer + format: int32 + readOnly: true + attributes: + $ref: '#/components/schemas/MethodAttributes' + methodImplementationFlags: + $ref: '#/components/schemas/MethodImplAttributes' + callingConvention: + $ref: '#/components/schemas/CallingConventions' + isAbstract: + type: boolean + readOnly: true + isConstructor: + type: boolean + readOnly: true + isFinal: + type: boolean + readOnly: true + isHideBySig: + type: boolean + readOnly: true + isSpecialName: + type: boolean + readOnly: true + isStatic: + type: boolean + readOnly: true + isVirtual: + type: boolean + readOnly: true + isAssembly: + type: boolean + readOnly: true + isFamily: + type: boolean + readOnly: true + isFamilyAndAssembly: + type: boolean + readOnly: true + isFamilyOrAssembly: + type: boolean + readOnly: true + isPrivate: + type: boolean + readOnly: true + isPublic: + type: boolean + readOnly: true + isConstructedGenericMethod: + type: boolean + readOnly: true + isGenericMethod: + type: boolean + readOnly: true + isGenericMethodDefinition: + type: boolean + readOnly: true + containsGenericParameters: + type: boolean + readOnly: true + methodHandle: + $ref: '#/components/schemas/RuntimeMethodHandle' + isSecurityCritical: + type: boolean + readOnly: true + isSecuritySafeCritical: + type: boolean + readOnly: true + isSecurityTransparent: + type: boolean + readOnly: true + memberType: + $ref: '#/components/schemas/MemberTypes' + returnParameter: + $ref: '#/components/schemas/ParameterInfo' + returnType: + $ref: '#/components/schemas/Type' + returnTypeCustomAttributes: + $ref: '#/components/schemas/ICustomAttributeProvider' + additionalProperties: false + Module: + type: object + properties: + assembly: + $ref: '#/components/schemas/Assembly' + fullyQualifiedName: + type: string + readOnly: true + name: + type: string + readOnly: true + mdStreamVersion: + type: integer + format: int32 + readOnly: true + moduleVersionId: + type: string + format: uuid + readOnly: true + scopeName: + type: string + readOnly: true + moduleHandle: + $ref: '#/components/schemas/ModuleHandle' + customAttributes: + type: array + items: + $ref: '#/components/schemas/CustomAttributeData' + readOnly: true + metadataToken: + type: integer + format: int32 + readOnly: true + additionalProperties: false + ModuleHandle: + type: object + properties: + mdStreamVersion: + type: integer + format: int32 + readOnly: true + additionalProperties: false + OperatorId: + enum: + - Equals + - In + type: string + ParameterAttributes: + enum: + - None + - In + - Out + - Lcid + - Retval + - Optional + - HasDefault + - HasFieldMarshal + - Reserved3 + - Reserved4 + - ReservedMask + type: string + ParameterInfo: + type: object + properties: + attributes: + $ref: '#/components/schemas/ParameterAttributes' + member: + $ref: '#/components/schemas/MemberInfo' + name: + type: string + nullable: true + readOnly: true + parameterType: + $ref: '#/components/schemas/Type' + position: + type: integer + format: int32 + readOnly: true + isIn: + type: boolean + readOnly: true + isLcid: + type: boolean + readOnly: true + isOptional: + type: boolean + readOnly: true + isOut: + type: boolean + readOnly: true + isRetval: + type: boolean + readOnly: true + defaultValue: + nullable: true + readOnly: true + rawDefaultValue: + nullable: true + readOnly: true + hasDefaultValue: + type: boolean + readOnly: true + customAttributes: + type: array + items: + $ref: '#/components/schemas/CustomAttributeData' + readOnly: true + metadataToken: + type: integer + format: int32 + readOnly: true + additionalProperties: false + Permission: + type: object + properties: + action: + type: string + constraint: + $ref: '#/components/schemas/Constraint' + additionalProperties: false + PolicyAttributeResponse: + type: object + properties: + key: + $ref: '#/components/schemas/AttributeKeyId' + value: + type: string + additionalProperties: false + PolicyContentRequest: + type: object + properties: + policyType: + $ref: '#/components/schemas/PolicyTypeId' + constraintOperand: + $ref: '#/components/schemas/ConstraintOperandId' + constraints: + type: array + items: + $ref: '#/components/schemas/Constraints' + additionalProperties: false + PolicyFileContent: + type: object + properties: + '@context': + type: array + items: { } + '@type': + type: string + '@id': + type: string + permission: + $ref: '#/components/schemas/Permission' + additionalProperties: false + PolicyResponse: + type: object + properties: + content: + $ref: '#/components/schemas/PolicyFileContent' + attributes: + type: array + items: + $ref: '#/components/schemas/AdditionalAttributes' + nullable: true + additionalProperties: false + PolicyTypeId: + enum: + - Access + - Usage + type: string + PolicyTypeResponse: + type: object + properties: + technicalKey: + type: string + type: + type: array + items: + $ref: '#/components/schemas/PolicyTypeId' + description: + type: string + useCase: + type: array + items: + $ref: '#/components/schemas/UseCaseId' + attribute: + type: array + items: + $ref: '#/components/schemas/PolicyAttributeResponse' + technicalEnforced: + type: boolean + additionalProperties: false + PropertyAttributes: + enum: + - None + - SpecialName + - RTSpecialName + - HasDefault + - Reserved2 + - Reserved3 + - Reserved4 + - ReservedMask + type: string + PropertyInfo: + type: object + properties: + name: + type: string + readOnly: true + declaringType: + $ref: '#/components/schemas/Type' + reflectedType: + $ref: '#/components/schemas/Type' + module: + $ref: '#/components/schemas/Module' + customAttributes: + type: array + items: + $ref: '#/components/schemas/CustomAttributeData' + readOnly: true + isCollectible: + type: boolean + readOnly: true + metadataToken: + type: integer + format: int32 + readOnly: true + memberType: + $ref: '#/components/schemas/MemberTypes' + propertyType: + $ref: '#/components/schemas/Type' + attributes: + $ref: '#/components/schemas/PropertyAttributes' + isSpecialName: + type: boolean + readOnly: true + canRead: + type: boolean + readOnly: true + canWrite: + type: boolean + readOnly: true + getMethod: + $ref: '#/components/schemas/MethodInfo' + setMethod: + $ref: '#/components/schemas/MethodInfo' + additionalProperties: false + RuntimeFieldHandle: + type: object + properties: + value: + $ref: '#/components/schemas/IntPtr' + additionalProperties: false + RuntimeMethodHandle: + type: object + properties: + value: + $ref: '#/components/schemas/IntPtr' + additionalProperties: false + RuntimeTypeHandle: + type: object + properties: + value: + $ref: '#/components/schemas/IntPtr' + additionalProperties: false + SecurityRuleSet: + enum: + - None + - Level1 + - Level2 + type: string + StructLayoutAttribute: + type: object + properties: + typeId: + readOnly: true + value: + $ref: '#/components/schemas/LayoutKind' + additionalProperties: false + Type: + type: object + properties: + name: + type: string + readOnly: true + customAttributes: + type: array + items: + $ref: '#/components/schemas/CustomAttributeData' + readOnly: true + isCollectible: + type: boolean + readOnly: true + metadataToken: + type: integer + format: int32 + readOnly: true + isInterface: + type: boolean + readOnly: true + memberType: + $ref: '#/components/schemas/MemberTypes' + namespace: + type: string + nullable: true + readOnly: true + assemblyQualifiedName: + type: string + nullable: true + readOnly: true + fullName: + type: string + nullable: true + readOnly: true + assembly: + $ref: '#/components/schemas/Assembly' + module: + $ref: '#/components/schemas/Module' + isNested: + type: boolean + readOnly: true + declaringType: + $ref: '#/components/schemas/Type' + declaringMethod: + $ref: '#/components/schemas/MethodBase' + reflectedType: + $ref: '#/components/schemas/Type' + underlyingSystemType: + $ref: '#/components/schemas/Type' + isTypeDefinition: + type: boolean + readOnly: true + isArray: + type: boolean + readOnly: true + isByRef: + type: boolean + readOnly: true + isPointer: + type: boolean + readOnly: true + isConstructedGenericType: + type: boolean + readOnly: true + isGenericParameter: + type: boolean + readOnly: true + isGenericTypeParameter: + type: boolean + readOnly: true + isGenericMethodParameter: + type: boolean + readOnly: true + isGenericType: + type: boolean + readOnly: true + isGenericTypeDefinition: + type: boolean + readOnly: true + isSZArray: + type: boolean + readOnly: true + isVariableBoundArray: + type: boolean + readOnly: true + isByRefLike: + type: boolean + readOnly: true + isFunctionPointer: + type: boolean + readOnly: true + isUnmanagedFunctionPointer: + type: boolean + readOnly: true + hasElementType: + type: boolean + readOnly: true + genericTypeArguments: + type: array + items: + $ref: '#/components/schemas/Type' + readOnly: true + genericParameterPosition: + type: integer + format: int32 + readOnly: true + genericParameterAttributes: + $ref: '#/components/schemas/GenericParameterAttributes' + attributes: + $ref: '#/components/schemas/TypeAttributes' + isAbstract: + type: boolean + readOnly: true + isImport: + type: boolean + readOnly: true + isSealed: + type: boolean + readOnly: true + isSpecialName: + type: boolean + readOnly: true + isClass: + type: boolean + readOnly: true + isNestedAssembly: + type: boolean + readOnly: true + isNestedFamANDAssem: + type: boolean + readOnly: true + isNestedFamily: + type: boolean + readOnly: true + isNestedFamORAssem: + type: boolean + readOnly: true + isNestedPrivate: + type: boolean + readOnly: true + isNestedPublic: + type: boolean + readOnly: true + isNotPublic: + type: boolean + readOnly: true + isPublic: + type: boolean + readOnly: true + isAutoLayout: + type: boolean + readOnly: true + isExplicitLayout: + type: boolean + readOnly: true + isLayoutSequential: + type: boolean + readOnly: true + isAnsiClass: + type: boolean + readOnly: true + isAutoClass: + type: boolean + readOnly: true + isUnicodeClass: + type: boolean + readOnly: true + isCOMObject: + type: boolean + readOnly: true + isContextful: + type: boolean + readOnly: true + isEnum: + type: boolean + readOnly: true + isMarshalByRef: + type: boolean + readOnly: true + isPrimitive: + type: boolean + readOnly: true + isValueType: + type: boolean + readOnly: true + isSignatureType: + type: boolean + readOnly: true + isSecurityCritical: + type: boolean + readOnly: true + isSecuritySafeCritical: + type: boolean + readOnly: true + isSecurityTransparent: + type: boolean + readOnly: true + structLayoutAttribute: + $ref: '#/components/schemas/StructLayoutAttribute' + typeInitializer: + $ref: '#/components/schemas/ConstructorInfo' + typeHandle: + $ref: '#/components/schemas/RuntimeTypeHandle' + guid: + type: string + format: uuid + readOnly: true + baseType: + $ref: '#/components/schemas/Type' + isSerializable: + type: boolean + readOnly: true + deprecated: true + containsGenericParameters: + type: boolean + readOnly: true + isVisible: + type: boolean + readOnly: true + additionalProperties: false + TypeAttributes: + enum: + - NotPublic + - Public + - NestedPublic + - NestedPrivate + - NestedFamily + - NestedAssembly + - NestedFamANDAssem + - VisibilityMask + - SequentialLayout + - ExplicitLayout + - LayoutMask + - Interface + - Abstract + - Sealed + - SpecialName + - RTSpecialName + - Import + - Serializable + - WindowsRuntime + - UnicodeClass + - AutoClass + - StringFormatMask + - HasSecurity + - ReservedMask + - BeforeFieldInit + - CustomFormatMask + type: string + TypeInfo: + type: object + properties: + name: + type: string + readOnly: true + customAttributes: + type: array + items: + $ref: '#/components/schemas/CustomAttributeData' + readOnly: true + isCollectible: + type: boolean + readOnly: true + metadataToken: + type: integer + format: int32 + readOnly: true + isInterface: + type: boolean + readOnly: true + memberType: + $ref: '#/components/schemas/MemberTypes' + namespace: + type: string + nullable: true + readOnly: true + assemblyQualifiedName: + type: string + nullable: true + readOnly: true + fullName: + type: string + nullable: true + readOnly: true + assembly: + $ref: '#/components/schemas/Assembly' + module: + $ref: '#/components/schemas/Module' + isNested: + type: boolean + readOnly: true + declaringType: + $ref: '#/components/schemas/Type' + declaringMethod: + $ref: '#/components/schemas/MethodBase' + reflectedType: + $ref: '#/components/schemas/Type' + underlyingSystemType: + $ref: '#/components/schemas/Type' + isTypeDefinition: + type: boolean + readOnly: true + isArray: + type: boolean + readOnly: true + isByRef: + type: boolean + readOnly: true + isPointer: + type: boolean + readOnly: true + isConstructedGenericType: + type: boolean + readOnly: true + isGenericParameter: + type: boolean + readOnly: true + isGenericTypeParameter: + type: boolean + readOnly: true + isGenericMethodParameter: + type: boolean + readOnly: true + isGenericType: + type: boolean + readOnly: true + isGenericTypeDefinition: + type: boolean + readOnly: true + isSZArray: + type: boolean + readOnly: true + isVariableBoundArray: + type: boolean + readOnly: true + isByRefLike: + type: boolean + readOnly: true + isFunctionPointer: + type: boolean + readOnly: true + isUnmanagedFunctionPointer: + type: boolean + readOnly: true + hasElementType: + type: boolean + readOnly: true + genericTypeArguments: + type: array + items: + $ref: '#/components/schemas/Type' + readOnly: true + genericParameterPosition: + type: integer + format: int32 + readOnly: true + genericParameterAttributes: + $ref: '#/components/schemas/GenericParameterAttributes' + attributes: + $ref: '#/components/schemas/TypeAttributes' + isAbstract: + type: boolean + readOnly: true + isImport: + type: boolean + readOnly: true + isSealed: + type: boolean + readOnly: true + isSpecialName: + type: boolean + readOnly: true + isClass: + type: boolean + readOnly: true + isNestedAssembly: + type: boolean + readOnly: true + isNestedFamANDAssem: + type: boolean + readOnly: true + isNestedFamily: + type: boolean + readOnly: true + isNestedFamORAssem: + type: boolean + readOnly: true + isNestedPrivate: + type: boolean + readOnly: true + isNestedPublic: + type: boolean + readOnly: true + isNotPublic: + type: boolean + readOnly: true + isPublic: + type: boolean + readOnly: true + isAutoLayout: + type: boolean + readOnly: true + isExplicitLayout: + type: boolean + readOnly: true + isLayoutSequential: + type: boolean + readOnly: true + isAnsiClass: + type: boolean + readOnly: true + isAutoClass: + type: boolean + readOnly: true + isUnicodeClass: + type: boolean + readOnly: true + isCOMObject: + type: boolean + readOnly: true + isContextful: + type: boolean + readOnly: true + isEnum: + type: boolean + readOnly: true + isMarshalByRef: + type: boolean + readOnly: true + isPrimitive: + type: boolean + readOnly: true + isValueType: + type: boolean + readOnly: true + isSignatureType: + type: boolean + readOnly: true + isSecurityCritical: + type: boolean + readOnly: true + isSecuritySafeCritical: + type: boolean + readOnly: true + isSecurityTransparent: + type: boolean + readOnly: true + structLayoutAttribute: + $ref: '#/components/schemas/StructLayoutAttribute' + typeInitializer: + $ref: '#/components/schemas/ConstructorInfo' + typeHandle: + $ref: '#/components/schemas/RuntimeTypeHandle' + guid: + type: string + format: uuid + readOnly: true + baseType: + $ref: '#/components/schemas/Type' + isSerializable: + type: boolean + readOnly: true + deprecated: true + containsGenericParameters: + type: boolean + readOnly: true + isVisible: + type: boolean + readOnly: true + genericTypeParameters: + type: array + items: + $ref: '#/components/schemas/Type' + readOnly: true + declaredConstructors: + type: array + items: + $ref: '#/components/schemas/ConstructorInfo' + readOnly: true + declaredEvents: + type: array + items: + $ref: '#/components/schemas/EventInfo' + readOnly: true + declaredFields: + type: array + items: + $ref: '#/components/schemas/FieldInfo' + readOnly: true + declaredMembers: + type: array + items: + $ref: '#/components/schemas/MemberInfo' + readOnly: true + declaredMethods: + type: array + items: + $ref: '#/components/schemas/MethodInfo' + readOnly: true + declaredNestedTypes: + type: array + items: + $ref: '#/components/schemas/TypeInfo' + readOnly: true + declaredProperties: + type: array + items: + $ref: '#/components/schemas/PropertyInfo' + readOnly: true + implementedInterfaces: + type: array + items: + $ref: '#/components/schemas/Type' + readOnly: true + additionalProperties: false + UseCaseId: + enum: + - Traceability + - Quality + - PCF + - Behavioraltwin + - Businesspartner + - CircularEconomy + - DemandCapacity + type: string + securitySchemes: + Bearer: + type: apiKey + description: "JWT Authorization header using the Bearer scheme. \r\n\r\n Enter 'Bearer' [space] and then your token in the text input below.\r\n\r\nExample: \"Bearer 12345abcdef\"" + name: Authorization + in: header +security: + - Bearer: [ ] \ No newline at end of file diff --git a/docs/technical-documentation/release-process/Release Process.md b/docs/technical-documentation/release-process/Release Process.md index 40d342df..dc725dca 100644 --- a/docs/technical-documentation/release-process/Release Process.md +++ b/docs/technical-documentation/release-process/Release Process.md @@ -2,10 +2,16 @@ The release process for a new version can roughly be divided into the following steps: -- [Preparations on the release branch](#preparations-on-the-release-branch) -- [Update CHANGELOG.md](#update-changelogmd) -- [Merge release branch](#merge-release-branch) -- [RC: provide successive rc branch and change base of open PRs](#rc-provide-successive-rc-branch-and-change-base-of-open-prs) +- [Release Process](#release-process) + - [Preparations on the release branch](#preparations-on-the-release-branch) + - [1. Aggregate migrations](#1-aggregate-migrations) + - [2. Version bump](#2-version-bump) + - [3. Update README (on chart level)](#3-update-readme-on-chart-level) + - [4. Update .tractusx](#4-update-tractusx) + - [Update CHANGELOG.md](#update-changelogmd) + - [Merge release branch](#merge-release-branch) + - [RC: provide successive rc branch and change base of open PRs](#rc-provide-successive-rc-branch-and-change-base-of-open-prs) + - [NOTICE](#notice) The process builds on the [Development Flow](../dev-process/Dev-flow_git-diagram.md) which, usually, takes place within forks and leads to merged pull requests in the repositories of the eclipse-tractusx organization. @@ -47,6 +53,22 @@ Example for commit message: _build: update readme for vx.x.x_ +### 4. Update .tractusx + +Adjust links of the open api specifications in the .tractusx file. + +All stable releases should be listed. In case of a pre-release version (rc, alpha, etc.), only the latest one should be listed. + +```md +openApiSpecs: +- "https://raw.githubusercontent.com/eclipse-tractusx/policy-hub/blob/v1.0.0/docs/api/hub-service.yaml" +- "https://raw.githubusercontent.com/eclipse-tractusx/policy-hub/blob/v1.1.0/docs/api/hub-service.yaml" +``` + +Example for commit message: + +_build: update open api spec for vx.x.x_ + ## Update CHANGELOG.md The changelog file tracks all notable changes since the last released version. diff --git a/src/database/PolicyHub.DbAccess/PolicyHub.DbAccess.csproj b/src/database/PolicyHub.DbAccess/PolicyHub.DbAccess.csproj index f7876d6b..2d45c585 100644 --- a/src/database/PolicyHub.DbAccess/PolicyHub.DbAccess.csproj +++ b/src/database/PolicyHub.DbAccess/PolicyHub.DbAccess.csproj @@ -33,8 +33,8 @@ - - + + diff --git a/src/database/PolicyHub.Migrations/PolicyHub.Migrations.csproj b/src/database/PolicyHub.Migrations/PolicyHub.Migrations.csproj index fa2ecd29..97b18dce 100644 --- a/src/database/PolicyHub.Migrations/PolicyHub.Migrations.csproj +++ b/src/database/PolicyHub.Migrations/PolicyHub.Migrations.csproj @@ -45,8 +45,8 @@ - - + + diff --git a/src/hub/PolicyHub.Service/.config/dotnet-tools.json b/src/hub/PolicyHub.Service/.config/dotnet-tools.json new file mode 100644 index 00000000..ba9187cc --- /dev/null +++ b/src/hub/PolicyHub.Service/.config/dotnet-tools.json @@ -0,0 +1,13 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "swashbuckle.aspnetcore.cli": { + "version": "6.8.0", + "commands": [ + "swagger" + ], + "rollForward": false + } + } +} \ No newline at end of file diff --git a/src/hub/PolicyHub.Service/PolicyHub.Service.csproj b/src/hub/PolicyHub.Service/PolicyHub.Service.csproj index 83fd06b8..ba86239d 100644 --- a/src/hub/PolicyHub.Service/PolicyHub.Service.csproj +++ b/src/hub/PolicyHub.Service/PolicyHub.Service.csproj @@ -32,11 +32,17 @@ 76bc0e20-3589-4626-a67e-bfca52afe9bb + + + + + + - + diff --git a/src/hub/PolicyHub.Service/Program.cs b/src/hub/PolicyHub.Service/Program.cs index e71d0bf2..9cfee94f 100644 --- a/src/hub/PolicyHub.Service/Program.cs +++ b/src/hub/PolicyHub.Service/Program.cs @@ -21,13 +21,14 @@ using Org.Eclipse.TractusX.PolicyHub.DbAccess.DependencyInjection; using Org.Eclipse.TractusX.PolicyHub.Service.Authentication; using Org.Eclipse.TractusX.PolicyHub.Service.Controllers; +using Org.Eclipse.TractusX.Portal.Backend.Framework.Models.Extensions; using Org.Eclipse.TractusX.Portal.Backend.Framework.Web; using System.Text.Json.Serialization; -const string Version = "v2"; +var version = AssemblyExtension.GetApplicationVersion(); await WebApplicationBuildRunner - .BuildAndRunWebApplicationAsync(args, "policy-hub", Version, ".Hub", + .BuildAndRunWebApplicationAsync(args, "policy-hub", version, ".Hub", builder => { builder.Services.AddTransient(); diff --git a/tests/hub/PolicyHub.Service.Tests/Controllers/PolicyHubControllerTests.cs b/tests/hub/PolicyHub.Service.Tests/Controllers/PolicyHubControllerTests.cs index e4ab24f2..97485ee6 100644 --- a/tests/hub/PolicyHub.Service.Tests/Controllers/PolicyHubControllerTests.cs +++ b/tests/hub/PolicyHub.Service.Tests/Controllers/PolicyHubControllerTests.cs @@ -276,19 +276,4 @@ public async Task GetPolicyContentWithFiltersAsync_MultipleConstraintsEqualsAndO } #endregion - - #region Swagger - - [Fact] - public async Task CheckSwagger_ReturnsExpected() - { - // Act - var response = await _client.GetAsync($"{BaseUrl}/swagger/v2/swagger.json"); - - // Assert - response.Should().NotBeNull(); - response.StatusCode.Should().Be(HttpStatusCode.OK); - } - - #endregion } diff --git a/tests/hub/PolicyHub.Service.Tests/Setup/IntegrationTestFactory.cs b/tests/hub/PolicyHub.Service.Tests/Setup/IntegrationTestFactory.cs index 72638b2e..84720e1c 100644 --- a/tests/hub/PolicyHub.Service.Tests/Setup/IntegrationTestFactory.cs +++ b/tests/hub/PolicyHub.Service.Tests/Setup/IntegrationTestFactory.cs @@ -50,15 +50,7 @@ public class IntegrationTestFactory : WebApplicationFactory - { - conf.AddJsonFile(configPath, true) - .AddUserSecrets(Assembly.GetExecutingAssembly(), true) - .AddEnvironmentVariables(); - }); + Environment.SetEnvironmentVariable("SKIP_CONFIGURATION_VALIDATION", "true"); builder.ConfigureTestServices(services => { services.ConfigureHttpJsonOptions(options => diff --git a/tests/hub/PolicyHub.Service.Tests/appsettings.IntegrationTests.json b/tests/hub/PolicyHub.Service.Tests/appsettings.IntegrationTests.json deleted file mode 100644 index 107e7db0..00000000 --- a/tests/hub/PolicyHub.Service.Tests/appsettings.IntegrationTests.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "Serilog": { - "Using": [ "Serilog.Sinks.Console" ], - "MinimumLevel": { - "Default": "Debug" - }, - "WriteTo": [ - { "Name": "Console" } - ], - "Enrich": [ - "WithCorrelationId" - ], - "Properties": { - "Application": "PolicyHub" - } - }, - "SwaggerEnabled": true, - "HealthChecks": [], - "Cors": { - "AllowedOrigins": [] - }, - "ConnectionStrings": { - "PolicyHubDb": "Server=placeholder;Database=placeholder;Port=5432;User Id=placeholder;Password=;Ssl Mode=Disable;" - }, - "JwtBearerOptions": { - "RequireHttpsMetadata": true, - "MetadataAddress": "", - "SaveToken": true, - "TokenValidationParameters": { - "ValidateIssuer": true, - "ValidIssuer": "", - "ValidateIssuerSigningKey": true, - "ValidAudience": "", - "ValidateAudience": true, - "ValidateLifetime": true, - "ClockSkew": 600000 - } - } -}