Skip to content

Commit

Permalink
docs: split openapi spec by plane
Browse files Browse the repository at this point in the history
  • Loading branch information
ndr-brt committed Jul 18, 2024
1 parent 1f40f32 commit 0ab6081
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 24 deletions.
75 changes: 56 additions & 19 deletions .github/workflows/publish-openapi-ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#################################################################################

---
name: "Publish OpenAPI to Swaggerhub"
name: publish openapi ui

on:
push:
Expand All @@ -34,12 +34,44 @@ on:
type: string

jobs:
swagger-api:
generate-openapi-spec:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-java

- name: Generate openapi spec
run: ./gradlew resolve
- uses: actions/upload-artifact@v4
with:
name: openapi-spec
path: resources/openapi/yaml

generate-swagger-ui:
needs: generate-openapi-spec
runs-on: ubuntu-latest
strategy:
matrix:
apiGroup: [
{
name: "control-plane",
folder: "edc-controlplane/edc-controlplane-base",
module: ":edc-controlplane:edc-controlplane-base"
},
{
name: "data-plane",
folder: "edc-dataplane/edc-dataplane-base",
module: ":edc-dataplane:edc-dataplane-base"
},
]
steps:
- uses: actions/checkout@v4
- uses: eclipse-edc/.github/.github/actions/setup-build@main
- uses: actions/download-artifact@v4
with:
name: openapi-spec
path: resources/openapi/yaml

- name: Set version
run: |
if [ -z ${{ inputs.version }} ]; then
Expand All @@ -50,39 +82,44 @@ jobs:
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
- name: Generate openapi spec
shell: bash
- name: Download upstream API specs for ${{ matrix.apiGroup.name }}
run: |
./gradlew resolve
- name: Download upstream API specs for control-plane and data-plane
run: |
./gradlew :edc-controlplane:edc-controlplane-base:downloadOpenapi
cp edc-controlplane/edc-controlplane-base/build/docs/openapi/* resources/openapi/yaml/
./gradlew :edc-dataplane:edc-dataplane-base:downloadOpenapi
cp edc-dataplane/edc-dataplane-base/build/docs/openapi/* resources/openapi/yaml/
./gradlew ${{ matrix.apiGroup.module }}:downloadOpenapi
cp ${{ matrix.apiGroup.folder }}/build/docs/openapi/* resources/openapi/yaml/
- name: Merge API specs
run: |
./gradlew -Pversion=${{ env.VERSION }} -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
./gradlew -Pversion=${{ env.VERSION }} -PapiTitle="Tractus-X EDC ${{ matrix.apiGroup.name }} API" -PapiDescription="Tractus-X EDC ${{ matrix.apiGroup.name }} API Documentation" :mergeApiSpec --input=./resources/openapi/yaml/${{ matrix.apiGroup.name }} --output=./resources/openapi/yaml/${{ matrix.apiGroup.name }}.yaml
- name: Generate Swagger UI current version
uses: Legion2/swagger-ui-action@v1
with:
output: openapi/${{ env.VERSION }}
spec-file: resources/openapi/yaml/tractusx-edc-api.yaml
output: dist/${{ matrix.apiGroup.name }}/${{ env.VERSION }}
spec-file: resources/openapi/yaml/${{ matrix.apiGroup.name }}/${{ matrix.apiGroup.name }}.yaml

- name: Generate Swagger UI stable version
uses: Legion2/swagger-ui-action@v1
if: ${{ !endsWith( env.VERSION, '-SNAPSHOT') }}
with:
output: openapi
spec-file: resources/openapi/yaml/tractusx-edc-api.yaml
output: dist/${{ matrix.apiGroup.name }}
spec-file: resources/openapi/yaml/${{ matrix.apiGroup.name }}/${{ matrix.apiGroup.name }}.yaml

- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.apiGroup.name }}-api
path: dist

deploy-swagger-ui:
needs: generate-swagger-ui
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
path: openapi
pattern: "*-api"
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: openapi
publish_dir: .
keep_files: true
1 change: 1 addition & 0 deletions .github/workflows/publish-swaggerhub.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#################################################################################


# DEPRECATED: openapi are published on github-pages now, please look at publish-openapi-ui
---
name: "Publish OpenAPI to Swaggerhub"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
plugins {
`java-library`
`maven-publish`
id("io.swagger.core.v3.swagger-gradle-plugin")
id(libs.plugins.swagger.get().pluginId)
}

dependencies {
Expand All @@ -33,3 +33,9 @@ dependencies {
testImplementation(libs.restAssured)
testImplementation(libs.edc.junit)
}

edcBuild {
swagger {
apiGroup.set("control-plane")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

plugins {
`java-library`
id("io.swagger.core.v3.swagger-gradle-plugin")
id(libs.plugins.swagger.get().pluginId)
}

dependencies {
Expand All @@ -43,3 +43,10 @@ dependencies {
testImplementation(libs.restAssured)
}

edcBuild {
swagger {
apiGroup.set("data-plane")
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
plugins {
`java-library`
`maven-publish`
id("io.swagger.core.v3.swagger-gradle-plugin")
id(libs.plugins.swagger.get().pluginId)
}

dependencies {
Expand All @@ -36,3 +36,8 @@ dependencies {
testImplementation(testFixtures(libs.edc.core.jersey))
}

edcBuild {
swagger {
apiGroup.set("data-plane")
}
}
9 changes: 8 additions & 1 deletion edc-extensions/edr/edr-api-v2/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
plugins {
`java-library`
`maven-publish`
id("io.swagger.core.v3.swagger-gradle-plugin")
id(libs.plugins.swagger.get().pluginId)
}

dependencies {
Expand All @@ -42,3 +42,10 @@ dependencies {
testImplementation(libs.edc.lib.transform)
testImplementation(libs.edc.spi.contract)
}

edcBuild {
swagger {
apiGroup.set("control-plane")
}
}

2 changes: 1 addition & 1 deletion edc-tests/runtime/mock-connector/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ plugins {
`java-library`
id("application")
id("com.github.johnrengelman.shadow") version "8.1.1"
id("io.swagger.core.v3.swagger-gradle-plugin")
id(libs.plugins.swagger.get().pluginId)
}


Expand Down
3 changes: 3 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -234,3 +234,6 @@ edc-dpf = ["edc.dpf-transfer-signaling", "edc.dpf-selector-core", "edc.spi-datap
edc-sqlstores = ["edc.sql-assetindex", "edc.sql-contract-definition", "edc.sql-contract-negotiation", "edc.sql-transferprocess", "edc.sql-policydef", "edc.sql-policy-monitor", "edc.sql-edrindex", "edc-transaction-local"]
edc-monitoring = ["edc.micrometer-core", "edc.micrometer-jersey", "edc.micrometer-jetty"]
edc-sts = ["edc-identity-trust-sts-core", "edc-identity-trust-sts-api", "edc-identity-trust-sts-client-configuration"]

[plugins]
swagger = { id = "io.swagger.core.v3.swagger-gradle-plugin", version = "2.2.22" }

0 comments on commit 0ab6081

Please sign in to comment.