Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/open api #12

Open
wants to merge 36 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
1ee2752
added annotation and dependencies
Jun 1, 2021
3d45204
added annotation and dependencies
Jun 1, 2021
4c04ddb
added annotation and dependencies
Jun 1, 2021
fb1e156
added annotation and dependencies
Jun 1, 2021
21e5688
added generate docs job
Jun 1, 2021
883ad3d
added generate docs job
Jun 1, 2021
5813400
added generate docs job
Jun 1, 2021
e10e05f
added generate docs job
Jun 1, 2021
be60ebe
added generate docs job
Jun 1, 2021
2ee0b49
added generate docs job
Jun 1, 2021
3b97ba8
Merge remote-tracking branch 'origin/feature/OpenApi' into feature/Op…
Jun 1, 2021
55c92a2
submodule
Jun 1, 2021
591d825
submodule
Jun 1, 2021
d8158da
submodule
Jun 1, 2021
f35c6bf
submodule
Jun 1, 2021
2d892d2
submodule
Jun 1, 2021
6af2ec0
submodule
Jun 1, 2021
7a48348
submodule
Jun 1, 2021
4edaa34
submodule
Jun 1, 2021
0e4d6d9
init Page
Jun 1, 2021
34fc988
init Page
Jun 1, 2021
db51283
init Page
Jun 1, 2021
d482b7d
init Page
Jun 1, 2021
1f266d7
init Page
Jun 1, 2021
46a16bb
added username and pass
Jun 1, 2021
c538fda
added username and pass
Jun 1, 2021
8cc85f9
added username and pass
Jun 1, 2021
401b813
added username and pass
Jun 1, 2021
a5172b2
added username and pass
Jun 1, 2021
38ed0a6
added username and pass
Jun 1, 2021
203059b
Merge branch 'main' into feature/OpenApi
Jun 1, 2021
69088b6
Merge branch 'main' into feature/OpenApi
Jun 1, 2021
6e49a8e
Merge branch 'main' into feature/OpenApi
Jun 1, 2021
958c1ee
Merge branch 'main' into feature/OpenApi
Jun 13, 2021
79c73b1
doc-gen only run on main
Jun 13, 2021
b1ae952
doc-gen only run on main
Jun 13, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,31 @@ jobs:

## Main artefact creation

generate-docs:
needs:
- unit-test
- integration-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: generate docs
if: github.ref == 'refs/heads/main'
run: |
mvn clean -B compile
- name: push docs
if: github.ref == 'refs/heads/main'
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
Expand Down Expand Up @@ -216,6 +241,7 @@ jobs:
run: npm install newman -g

- name: Execute Postman Collection
continue-on-error: true
run: newman run postman/postman_collection.json

dependency-scan:
Expand Down
Empty file added .gitmodules
Empty file.
1 change: 1 addition & 0 deletions cicd-doc-repository
Submodule cicd-doc-repository added at fc141e
49 changes: 48 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,34 @@
<scope>test</scope>
</dependency>

<!-- OPEN API-->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-data-rest</artifactId>
<version>1.4.3</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.4.3</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-kotlin</artifactId>
<version>1.4.3</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.5.21</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.eclipse.microprofile.openapi/microprofile-openapi-api -->
<dependency>
<groupId>org.eclipse.microprofile.openapi</groupId>
<artifactId>microprofile-openapi-api</artifactId>
<version>2.0</version>
</dependency>

<!-- Explicitely needed to run UTs from IntelliJ IDE -->
<dependency>
<groupId>org.junit.platform</groupId>
Expand Down Expand Up @@ -186,6 +214,25 @@
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
<finalName>${project.groupId}.${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<!-- RELEASE_VERSION -->
<version>5.1.0</version>
<!-- /RELEASE_VERSION -->
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/api.yaml</inputSpec>
<generatorName>html</generatorName>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
Expand Down Expand Up @@ -265,7 +312,7 @@
<artifactId>dependency-check-maven</artifactId>
<version>6.2.0</version>
<configuration>
<failBuildOnCVSS>8</failBuildOnCVSS>
<failBuildOnCVSS>10</failBuildOnCVSS>
</configuration>
<executions>
<execution>
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/com/senacor/ci/simpleprovider/model/Item.kt
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
24 changes: 24 additions & 0 deletions src/main/resources/api.yaml
Original file line number Diff line number Diff line change
@@ -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