From 5a45c36293e5d5b422e70486c349939f6b28b988 Mon Sep 17 00:00:00 2001 From: Paul Latzelsperger <43503240+paullatzelsperger@users.noreply.github.com> Date: Wed, 9 Aug 2023 09:38:57 +0200 Subject: [PATCH] fix: openapi publication (#698) --- .github/workflows/publish-swaggerhub.yaml | 36 +- .github/workflows/publish.yaml | 3 +- .../edc/api/bpn/BusinessPartnerGroupApi.java | 2 +- .../edc-dataplane-proxy-consumer-api.yaml | 43 -- resources/openapi/yaml/edr-api.yaml | 488 ------------------ 5 files changed, 30 insertions(+), 542 deletions(-) delete mode 100644 resources/openapi/yaml/edc-dataplane-proxy-consumer-api.yaml delete mode 100644 resources/openapi/yaml/edr-api.yaml diff --git a/.github/workflows/publish-swaggerhub.yaml b/.github/workflows/publish-swaggerhub.yaml index e9e05f048..b09c8e436 100644 --- a/.github/workflows/publish-swaggerhub.yaml +++ b/.github/workflows/publish-swaggerhub.yaml @@ -31,6 +31,17 @@ on: required: false type: string + workflow_dispatch: + inputs: + downstream-version: + required: false + description: "Version of the Tractus-X EDC API to be should be published" + type: string + upstream-version: + required: false + description: "Version of upstream EDC which is to be used" + type: string + jobs: swagger-api: runs-on: ubuntu-latest @@ -50,38 +61,39 @@ jobs: - name: Setup node uses: actions/setup-node@v3 - - name: Install tools + - name: Install Swagger CLI run: | npm i -g swaggerhub-cli - name: Extract versions run: | if [ -z ${{ inputs.downstream-version }} ]; then - export DOWNSTREAM_VERSION=$(sed -nr "{ :l /^version[ ]*=/ { s/[^=]*=[ ]*//; p; q;}; n; b l;}" ./gradle.properties | tr -d ' ' | tr -d '"') + export DOWNSTREAM_VERSION=$(grep "version" gradle.properties | awk -F= '{print $2}') else export DOWNSTREAM_VERSION=${{ inputs.downstream-version }} fi if [ -z ${{ inputs.upstream-version }} ]; then - export UPSTREAM_VERSION=$(sed -nr "/^\[versions\]/ { :l /^edc[ ]*=/ { s/[^=]*=[ ]*//; p; q;}; n; b l;}" ./gradle/libs.versions.toml | tr -d ' ' | tr -d '"')-SNAPSHOT + export UPSTREAM_VERSION=$(grep "edc = " gradle/libs.versions.toml | awk -F= '{print $2}' | jq -r) else export UPSTREAM_VERSION=${{ inputs.upstream-version }} fi + echo "DOWNSTREAM_VERSION=$DOWNSTREAM_VERSION" >> "$GITHUB_ENV" + echo "UPSTREAM_VERSION=$UPSTREAM_VERSION" >> "$GITHUB_ENV" - name: Resolve TX EDC API Spec shell: bash run: | - ./gradlew :edc-extensions:dataplane-proxy:edc-dataplane-proxy-provider-api:resolve - ./gradlew :edc-extensions:dataplane-proxy:edc-dataplane-proxy-consumer-api:resolve + ./gradlew resolve - name: Download upstream API specs run: | - swaggerhub api:get eclipse-edc-bot/management-api/${{ env.UPSTREAM_VERSION }} > resources/openapi/yaml/upstream-management-api.yaml - swaggerhub api:get eclipse-edc-bot/control-api/${{ env.UPSTREAM_VERSION }} > resources/openapi/yaml/upstream-control-api.yaml + curl -X GET https://api.swaggerhub.com/apis/eclipse-edc-bot/management-api/${{ env.UPSTREAM_VERSION }}/swagger.yaml > resources/openapi/yaml/upstream-management-api.yaml + curl -X GET https://api.swaggerhub.com/apis/eclipse-edc-bot/control-api/${{ env.UPSTREAM_VERSION }}/swagger.yaml > resources/openapi/yaml/upstream-control-api.yaml - name: Merge API specs run: | - ./gradlew -PapiTitle="tractusx-edc-api" -PapiDescription="Tractus EDC API Doc" :mergeApiSpec --input=./resources/openapi/yaml --output=./resources/openapi/yaml/tractusx-edc-api.yaml + ./gradlew -PapiTitle="Tractus-X EDC REST API" -PapiDescription="Tractus-X EDC API Documentation" :mergeApiSpec --input=./resources/openapi/yaml --output=./resources/openapi/yaml/tractusx-edc-api.yaml # create API, will fail if exists - name: Create API @@ -92,4 +104,10 @@ jobs: # Post the API to SwaggerHub as "unpublished", because published APIs cannot be overwritten - name: Publish API Specs to SwaggerHub run: | - swaggerhub api:update ${{ env.SWAGGERHUB_USER }}/tractusx-edc/${{ env.DOWNSTREAM_VERSION }} -f ./resources/openapi/yaml/tractusx-edc-api.yaml --visibility=public --published=unpublish + if [[ ${{ env.DOWNSTREAM_VERSION }} != *-SNAPSHOT ]]; then + echo "no snapshot, will set the API to 'published'"; + swaggerhub api:update ${{ env.SWAGGERHUB_USER }}/tractusx-edc/${{ env.DOWNSTREAM_VERSION }} -f ./resources/openapi/yaml/tractusx-edc-api.yaml --visibility=public --published=publish + else + echo "snapshot, will set the API to 'unpublished'"; + swaggerhub api:update ${{ env.SWAGGERHUB_USER }}/tractusx-edc/${{ env.DOWNSTREAM_VERSION }} -f ./resources/openapi/yaml/tractusx-edc-api.yaml --visibility=public --published=unpublish + fi \ No newline at end of file diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 0178b8de6..a61da2b23 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -135,5 +135,6 @@ jobs: permissions: contents: read needs: [ secret-presence ] - if: needs.secret-presence.output.HAS_SWAGGER + if: needs.secret-presence.outputs.HAS_SWAGGER uses: ./.github/workflows/publish-swaggerhub.yaml + secrets: inherit diff --git a/edc-extensions/bpn-validation/bpn-validation-api/src/main/java/org/eclipse/tractusx/edc/api/bpn/BusinessPartnerGroupApi.java b/edc-extensions/bpn-validation/bpn-validation-api/src/main/java/org/eclipse/tractusx/edc/api/bpn/BusinessPartnerGroupApi.java index 05038192f..1c57262ca 100644 --- a/edc-extensions/bpn-validation/bpn-validation-api/src/main/java/org/eclipse/tractusx/edc/api/bpn/BusinessPartnerGroupApi.java +++ b/edc-extensions/bpn-validation/bpn-validation-api/src/main/java/org/eclipse/tractusx/edc/api/bpn/BusinessPartnerGroupApi.java @@ -39,7 +39,7 @@ import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; @OpenAPIDefinition(info = @Info(description = "With this API clients can create, read, update and delete BusinessPartnerNumber groups. It allows the assigning of BPNs to groups.", title = "Business Partner Group API")) -@Tag(name = "BusinessPartnerGroup") +@Tag(name = "Business Partner Group") public interface BusinessPartnerGroupApi { diff --git a/resources/openapi/yaml/edc-dataplane-proxy-consumer-api.yaml b/resources/openapi/yaml/edc-dataplane-proxy-consumer-api.yaml deleted file mode 100644 index edf1712cd..000000000 --- a/resources/openapi/yaml/edc-dataplane-proxy-consumer-api.yaml +++ /dev/null @@ -1,43 +0,0 @@ -openapi: 3.0.1 -paths: - /aas/request: - post: - operationId: requestAsset - requestBody: - content: - '*/*': - schema: - $ref: '#/components/schemas/AssetRequest' - responses: - default: - content: - application/json: - schema: - $ref: '#/components/schemas/AssetRequest' - description: Requests asset data - tags: - - Data Plane Proxy API -components: - schemas: - AssetRequest: - type: object - example: null - properties: - assetId: - type: string - example: null - endpointUrl: - type: string - example: null - pathSegments: - type: string - example: null - providerId: - type: string - example: null - queryParams: - type: string - example: null - transferProcessId: - type: string - example: null diff --git a/resources/openapi/yaml/edr-api.yaml b/resources/openapi/yaml/edr-api.yaml deleted file mode 100644 index 28518d5d5..000000000 --- a/resources/openapi/yaml/edr-api.yaml +++ /dev/null @@ -1,488 +0,0 @@ -openapi: 3.0.1 -paths: - /edrs: - get: - description: Returns all EndpointDataReference entry according to a query - operationId: queryEdrs - parameters: - - in: query - name: assetId - schema: - type: string - example: null - - in: query - name: agreementId - schema: - type: string - example: null - - in: query - name: providerId - schema: - type: string - example: null - responses: - "200": - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/EndpointDataReferenceEntry' - "400": - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - description: Request was malformed - tags: - - Control Plane EDR Api - post: - description: Initiates an EDR negotiation by handling a contract negotiation - first and then a transfer process for a given offer and with the given counter - part. Please note that successfully invoking this endpoint only means that - the negotiation was initiated. - operationId: initiateEdrNegotiation - requestBody: - content: - application/json: - schema: - type: object - additionalProperties: - $ref: '#/components/schemas/NegotiateEdrRequestDto' - example: null - properties: - empty: - type: boolean - example: null - valueType: - type: string - enum: - - ARRAY - - OBJECT - - STRING - - NUMBER - - "TRUE" - - "FALSE" - - "NULL" - example: null - responses: - "200": - content: - application/json: - schema: - $ref: '#/components/schemas/IdResponse' - description: The negotiation was successfully initiated. - "400": - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - description: Request body was malformed - tags: - - Control Plane EDR Api - /edrs/{id}: - delete: - description: Delete an EDR with the given transfer process ID - operationId: deleteEdr - parameters: - - in: path - name: id - required: true - schema: - type: string - example: null - responses: - "200": - content: - application/json: - schema: - $ref: '#/components/schemas/DataAddress' - description: The EDR cached - "400": - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - description: "Request was malformed, e.g. id was null" - "404": - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - description: An EDR with the given ID does not exist - tags: - - Control Plane EDR Api - get: - description: Gets an EDR with the given transfer process ID - operationId: getEdr - parameters: - - in: path - name: id - required: true - schema: - type: string - example: null - responses: - "200": - content: - application/json: - schema: - $ref: '#/components/schemas/DataAddress' - description: The EDR cached - "400": - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - description: "Request was malformed, e.g. id was null" - "404": - content: - application/json: - schema: - type: array - example: null - items: - $ref: '#/components/schemas/ApiErrorDetail' - description: An EDR with the given ID does not exist - tags: - - Control Plane EDR Api -components: - schemas: - Action: - type: object - example: null - properties: - constraint: - $ref: '#/components/schemas/Constraint' - includedIn: - type: string - example: null - type: - type: string - example: null - ApiErrorDetail: - type: object - example: null - properties: - invalidValue: - type: object - example: null - message: - type: string - example: null - path: - type: string - example: null - type: - type: string - example: null - CallbackAddress: - type: object - example: null - properties: - authCodeId: - type: string - example: null - authKey: - type: string - example: null - events: - type: array - example: null - items: - type: string - example: null - uniqueItems: true - transactional: - type: boolean - example: null - uri: - type: string - example: null - Constraint: - type: object - discriminator: - propertyName: edctype - example: null - properties: - edctype: - type: string - example: null - required: - - edctype - ContractOfferDescription: - type: object - example: null - properties: - assetId: - type: string - example: null - offerId: - type: string - example: null - policy: - $ref: '#/components/schemas/Policy' - DataAddress: - type: object - example: null - properties: - '@type': - type: string - example: https://w3id.org/edc/v0.0.1/ns/DataAddress - type: - type: string - example: null - Duty: - type: object - example: null - properties: - action: - $ref: '#/components/schemas/Action' - assignee: - type: string - example: null - assigner: - type: string - example: null - consequence: - $ref: '#/components/schemas/Duty' - constraints: - type: array - example: null - items: - $ref: '#/components/schemas/Constraint' - parentPermission: - $ref: '#/components/schemas/Permission' - target: - type: string - example: null - EndpointDataReferenceEntry: - type: object - example: null - properties: - agreementId: - type: string - example: null - assetId: - type: string - example: null - createdAt: - type: integer - format: int64 - example: null - errorDetail: - type: string - example: null - expirationTimestamp: - type: integer - format: int64 - example: null - id: - type: string - example: null - providerId: - type: string - example: null - state: - type: integer - format: int32 - example: null - stateCount: - type: integer - format: int32 - example: null - stateTimestamp: - type: integer - format: int64 - example: null - traceContext: - type: object - additionalProperties: - type: string - example: null - example: null - transferProcessId: - type: string - example: null - updatedAt: - type: integer - format: int64 - example: null - IdResponse: - type: object - example: - '@context': - edc: https://w3id.org/edc/v0.0.1/ns/ - '@id': id-value - createdAt: 1688465655 - properties: - '@id': - type: string - example: null - createdAt: - type: integer - format: int64 - example: null - JsonObject: - type: object - additionalProperties: - $ref: '#/components/schemas/JsonValue' - example: null - properties: - empty: - type: boolean - example: null - valueType: - type: string - enum: - - ARRAY - - OBJECT - - STRING - - NUMBER - - "TRUE" - - "FALSE" - - "NULL" - example: null - JsonValue: - type: object - example: null - properties: - valueType: - type: string - enum: - - ARRAY - - OBJECT - - STRING - - NUMBER - - "TRUE" - - "FALSE" - - "NULL" - example: null - NegotiateEdrRequestDto: - type: object - example: null - properties: - callbackAddresses: - type: array - example: null - items: - $ref: '#/components/schemas/CallbackAddress' - connectorAddress: - type: string - example: null - connectorId: - type: string - example: null - offer: - $ref: '#/components/schemas/ContractOfferDescription' - protocol: - type: string - example: null - providerId: - type: string - example: null - Permission: - type: object - example: null - properties: - action: - $ref: '#/components/schemas/Action' - assignee: - type: string - example: null - assigner: - type: string - example: null - constraints: - type: array - example: null - items: - $ref: '#/components/schemas/Constraint' - duties: - type: array - example: null - items: - $ref: '#/components/schemas/Duty' - target: - type: string - example: null - Policy: - type: object - example: null - properties: - '@type': - type: string - enum: - - SET - - OFFER - - CONTRACT - example: null - assignee: - type: string - example: null - assigner: - type: string - example: null - extensibleProperties: - type: object - additionalProperties: - type: object - example: null - example: null - inheritsFrom: - type: string - example: null - obligations: - type: array - example: null - items: - $ref: '#/components/schemas/Duty' - permissions: - type: array - example: null - items: - $ref: '#/components/schemas/Permission' - prohibitions: - type: array - example: null - items: - $ref: '#/components/schemas/Prohibition' - target: - type: string - example: null - Prohibition: - type: object - example: null - properties: - action: - $ref: '#/components/schemas/Action' - assignee: - type: string - example: null - assigner: - type: string - example: null - constraints: - type: array - example: null - items: - $ref: '#/components/schemas/Constraint' - target: - type: string - example: null