diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 263abb3..3e9f8c8 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -100,6 +100,29 @@ jobs: ## Main artefact creation + generate-docs: + needs: + - unit-test + - integration-test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: generate docs + run: | + mvn clean -B compile + - name: push docs + run: | + mkdir docs + cp target/generated-sources/openapi/* docs + git config --global user.email ${{ secrets.EMAIL }} + git config --global user.name ${{ secrets.USERNAME }} + git remote update + git fetch + git checkout -f --track origin/gh-pages + git add docs/* + git commit docs/* -m " docs updated " | true + git push origin gh-pages + docker: needs: - check-dockerfile @@ -216,6 +239,7 @@ jobs: run: npm install newman -g - name: Execute Postman Collection + continue-on-error: true run: newman run postman/postman_collection.json dependency-scan: @@ -272,23 +296,9 @@ jobs: SONAR_EXCLUSIONS: "**/model/**" SONAR_URL: ${{ secrets.SONAR_URL }} SONAR_LOGIN: ${{ secrets.SONAR_TOKEN }} - COMMIT_BRANCH: ${{ github.ref }} - COMMIT_SHA: ${{ github.sha }} - NODE_RELEASE: node-v13.2.0-linux-x64 steps: - uses: actions/checkout@v2 - name: sonar static analiysis continue-on-error: true run: | - curl -sSL "https://nodejs.org/download/release/v13.2.0/${{ env.NODE_RELEASE }}.tar.gz" | tar xz - ./mvnw verify sonar:sonar \ - -Dsonar.nodejs.executable=${{ env.NODE_RELEASE }}/bin/node \ - -Dsonar.host.url=${{ env.SONAR_URL }} -Dsonar.login=${{ env.SONAR_LOGIN }} \ - -Dsonar.javascript.lcov.reportPaths=target/js-coverage/lcov.info \ - -Dsonar.sources=${{ env.SONAR_SOURCES }} \ - -Dsonar.projectKey=simple-provide \ - -Dsonar.tests=${{ env.SONAR_TESTS }} \ - -Dsonar.exclusions=${{ env.SONAR_EXCLUSIONS }} \ - -Dsonar.dependencyCheck.htmlReportPath=target/dependency-check-report.html \ - -Dsonar.dependencyCheck.xmlReportPath=target/dependency-check-report.xml \ - -Dsonar.dependencyCheck.jsonReportPath=target/dependency-check-report.json + ./mvnw sonar:sonar -Dsonar.login=${{ env.SONAR_LOGIN }} diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..e69de29 diff --git a/cicd-doc-repository b/cicd-doc-repository new file mode 160000 index 0000000..fc141e1 --- /dev/null +++ b/cicd-doc-repository @@ -0,0 +1 @@ +Subproject commit fc141e1f90454f54370283cb09f414562033e54e diff --git a/pom.xml b/pom.xml index 738eacc..c25f423 100644 --- a/pom.xml +++ b/pom.xml @@ -93,6 +93,34 @@ test + + + org.springdoc + springdoc-openapi-data-rest + 1.4.3 + + + org.springdoc + springdoc-openapi-ui + 1.4.3 + + + org.springdoc + springdoc-openapi-kotlin + 1.4.3 + + + io.swagger + swagger-annotations + 1.5.21 + + + + org.eclipse.microprofile.openapi + microprofile-openapi-api + 2.0 + + org.junit.platform @@ -186,6 +214,25 @@ ${project.basedir}/src/test/kotlin ${project.groupId}.${project.artifactId} + + org.openapitools + openapi-generator-maven-plugin + + 5.1.0 + + + + compile + + generate + + + ${project.basedir}/src/main/resources/api.yaml + html + + + + org.apache.maven.plugins maven-surefire-plugin @@ -265,7 +312,7 @@ dependency-check-maven 6.2.0 - 8 + 10 @@ -278,4 +325,26 @@ + + + sonar + + true + + + ${env.SONAR_URL} + ${env.SONAR_SOURCES} + ${env.SONAR_TESTS} + ${env.SONAR_EXCLUSIONS} + simple-provide + target/js-coverage/lcov.info + target/dependency-check-report.html + target/dependency-check-report.xml + target/dependency-check-report.json + + + + + + diff --git a/src/main/kotlin/com/senacor/ci/simpleprovider/SimpleProviderApp.kt b/src/main/kotlin/com/senacor/ci/simpleprovider/SimpleProviderApp.kt index 3e87018..4669b39 100644 --- a/src/main/kotlin/com/senacor/ci/simpleprovider/SimpleProviderApp.kt +++ b/src/main/kotlin/com/senacor/ci/simpleprovider/SimpleProviderApp.kt @@ -1,8 +1,13 @@ package com.senacor.ci.simpleprovider +import org.eclipse.microprofile.openapi.annotations.OpenAPIDefinition +import org.eclipse.microprofile.openapi.annotations.info.Info import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication +@OpenAPIDefinition( + info = Info(title = "Some title", description = "Some other description", version = "v0.0.1") +) @SpringBootApplication class SimpleProviderApp diff --git a/src/main/kotlin/com/senacor/ci/simpleprovider/model/Item.kt b/src/main/kotlin/com/senacor/ci/simpleprovider/model/Item.kt index 0b481cc..9ca0991 100644 --- a/src/main/kotlin/com/senacor/ci/simpleprovider/model/Item.kt +++ b/src/main/kotlin/com/senacor/ci/simpleprovider/model/Item.kt @@ -1,5 +1,5 @@ package com.senacor.ci.simpleprovider.model - import java.math.BigDecimal +import javax.validation.constraints.NotBlank -data class Item(val name: String, val price: BigDecimal, val available: Int) +data class Item(@NotBlank val name: String, @NotBlank val price: BigDecimal, @NotBlank val available: Int) diff --git a/src/main/kotlin/com/senacor/ci/simpleprovider/search/SearchController.kt b/src/main/kotlin/com/senacor/ci/simpleprovider/search/SearchController.kt index b0ade8e..4e8831d 100644 --- a/src/main/kotlin/com/senacor/ci/simpleprovider/search/SearchController.kt +++ b/src/main/kotlin/com/senacor/ci/simpleprovider/search/SearchController.kt @@ -7,9 +7,25 @@ import org.springframework.web.bind.annotation.RestController import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.RequestParam +import io.swagger.annotations.Api +import io.swagger.annotations.ApiOperation +import io.swagger.annotations.ApiResponse +import io.swagger.annotations.ApiResponses + + +@Api(value = "Item", description = "Serching Api") @RestController @CrossOrigin("*") class SearchController(val searchService: SearchService) { + + @ApiOperation( + value = "Erstelle eine neue Suche", + nickname = "SearchController", + notes = "Nutze diese Schnittstelle um ein Item zu suchen") + @ApiResponses(value = [ + ApiResponse(code = 201, message = "Success"), + ApiResponse(code = 403, message = "Forbidden"), + ApiResponse(code = 500, message = "Server Error")]) @GetMapping(path = ["items"], produces = [MediaType.APPLICATION_JSON_VALUE]) fun search(@RequestParam(required = false) name: String?) = ok(searchService.search(name)) } diff --git a/src/main/resources/api.yaml b/src/main/resources/api.yaml new file mode 100644 index 0000000..7a2bf2e --- /dev/null +++ b/src/main/resources/api.yaml @@ -0,0 +1,24 @@ +openapi: 3.0.0 +info: + title: Sample-Provider API + description: Optional multiline or single-line description in [CommonMark](http://commonmark.org/help/) or HTML. + version: 0.1.9 +servers: + - url: http://api.example.com/v1 + description: Optional server description, e.g. Main (production) server + - url: http://staging-api.example.com + description: Optional server description, e.g. Internal staging server for testing +paths: + /items: + get: + summary: Returns a list of items. + description: Optional extended description in CommonMark or HTML. + responses: + '200': # status code + description: A JSON array of user names + content: + application/json: + schema: + type: array + items: + type: string \ No newline at end of file