-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: generate, merge and publish OpenAPI spec 2 (#619)
* Automatically create API spec Signed-off-by: Brendan Cronin <[email protected]> * Bump Signed-off-by: Brendan Cronin <[email protected]> * Bump Signed-off-by: Brendan Cronin <[email protected]> * Bump Signed-off-by: Brendan Cronin <[email protected]> * Bump Signed-off-by: Brendan Cronin <[email protected]> * Bump Signed-off-by: Brendan Cronin <[email protected]> * Bump Signed-off-by: Brendan Cronin <[email protected]> * Bump Signed-off-by: Brendan Cronin <[email protected]> * Bump Signed-off-by: Brendan Cronin <[email protected]> * Bump Signed-off-by: Brendan Cronin <[email protected]> * Bump Signed-off-by: Brendan Cronin <[email protected]> * Bump Signed-off-by: Brendan Cronin <[email protected]> * Bump Signed-off-by: Brendan Cronin <[email protected]> * Bump Signed-off-by: Brendan Cronin <[email protected]> * Bump Signed-off-by: Brendan Cronin <[email protected]> * Bump Signed-off-by: Brendan Cronin <[email protected]> * Bump Signed-off-by: Brendan Cronin <[email protected]> * Bump Signed-off-by: Brendan Cronin <[email protected]> * Bump Signed-off-by: Brendan Cronin <[email protected]> * Bump Signed-off-by: Brendan Cronin <[email protected]> * Bump Signed-off-by: Brendan Cronin <[email protected]> * Bump Signed-off-by: Brendan Cronin <[email protected]> * Bump Signed-off-by: Brendan Cronin <[email protected]> * Bump Signed-off-by: Brendan Cronin <[email protected]> * Allow for direct version input Signed-off-by: Brendan Cronin <[email protected]> * Add Signed-off-by: Brendan Cronin <[email protected]> * Test Signed-off-by: Brendan Cronin <[email protected]> * Remove trigger Signed-off-by: Brendan Cronin <[email protected]> * Add trigger Signed-off-by: Brendan Cronin <[email protected]> * Remove trigger Signed-off-by: Brendan Cronin <[email protected]> --------- Signed-off-by: Brendan Cronin <[email protected]>
- Loading branch information
Showing
6 changed files
with
116 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# | ||
# Copyright (c) 2023 Mercedes-Benz Tech Innovation GmbH | ||
# Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation | ||
# | ||
# See the NOTICE file(s) distributed with this work for additional | ||
# information regarding copyright ownership. | ||
# | ||
# This program and the accompanying materials are made available under the | ||
# terms of the Apache License, Version 2.0 which is available at | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
--- | ||
name: "Publish OpenAPI to Swaggerhub" | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
downstream-version: | ||
required: false | ||
type: string | ||
upstream-version: | ||
required: false | ||
type: string | ||
|
||
jobs: | ||
swagger-api: | ||
runs-on: ubuntu-latest | ||
env: | ||
SWAGGERHUB_API_KEY: ${{ secrets.SWAGGERHUB_API_KEY }} | ||
SWAGGERHUB_USER: ${{ secrets.SWAGGERHUB_USER }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup JDK 17 | ||
uses: actions/[email protected] | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
cache: 'gradle' | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v3 | ||
|
||
- name: Install tools | ||
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 '"') | ||
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 | ||
else | ||
export UPSTREAM_VERSION=${{ inputs.upstream-version }} | ||
fi | ||
- 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 | ||
- 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 | ||
- 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 | ||
# create API, will fail if exists | ||
- name: Create API | ||
continue-on-error: true | ||
run: | | ||
swaggerhub api:create ${{ env.SWAGGERHUB_USER }}/tractusx-edc/${{ env.DOWNSTREAM_VERSION }} -f ./resources/openapi/yaml/tractusx-edc-api.yaml --visibility=public --published=unpublish | ||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 0 additions & 12 deletions
12
resources/openapi/yaml/edc-dataplane-proxy-provider-api.yaml
This file was deleted.
Oops, something went wrong.
105 changes: 0 additions & 105 deletions
105
resources/openapi/yaml/observability-api-customization.yaml
This file was deleted.
Oops, something went wrong.