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

Evaluating swagger-ui part of application #18

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
78 changes: 78 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@
<artifactId>springfox-bean-validators</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this? as we are manually downloading and unzip in unpack goal.

<artifactId>swagger-ui</artifactId>
<version>3.23.0</version>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -139,4 +144,77 @@
</plugins>
</build>

<profiles>
<profile>
<id> swagger-ui </id>
<build>
<plugins>
<!-- Step 1. - Download Swagger UI webjar -->
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>swagger ui</id>
<phase>prepare-package</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.webjars</groupId>
<artifactId>swagger-ui</artifactId>
<version>3.23.0</version>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}/swagger-ui</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<!-- Step 2. Add Swagger-ui Resources to the WAR -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources combine.children = "append">
<resource>
<directory>${project.build.directory}/swagger-ui/META-INF/resources/webjars/swagger-ui/3.23.0</directory>
<includes>
<include>**/*.*</include>
</includes>
<targetPath>swagger-ui</targetPath>
</resource>
</webResources>
</configuration>
</plugin>

<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<file>${project.build.directory}/swagger-ui/META-INF/resources/webjars/swagger-ui/3.23.0/index.html</file>
<replacements>
<replacement>
<token>https://petstore.swagger.io/v2/swagger.json</token>
<value>http://localhost:8080/metatdataswaggerui/openapi.json</value>
</replacement>
</replacements>
</configuration>
</plugin>

</plugins>
</build>
</profile>
</profiles>

</project>
3 changes: 3 additions & 0 deletions src/main/java/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<session-config>
<tracking-mode>COOKIE</tracking-mode>
</session-config>
10 changes: 10 additions & 0 deletions src/main/java/webapp/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<body>
<center>
<h1>
Metadata Swagger UI
</h1>
</center>
</body>
</html>
256 changes: 256 additions & 0 deletions src/main/java/webapp/openapi.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,256 @@
{
tskir marked this conversation as resolved.
Show resolved Hide resolved
"openapi": "3.0.2",
"info": {
"title": "AMP T2D Property registry API",
"description": "Property registry API for the project AMP-T2D",
"version": "1.0SNAPSHOT",
"termsOfService": "www.ebi.ac.uk/terms",
"contact": {
"name": "Property registry API Admin",
"url": "www.ebi.ac.uk",
"email": "[email protected]"
},
"license": {
"name": "Apache 2.0",
"url": "https://www.apache.org/license/"
}
},
"servers": [
{
"url": "https://www.ebi.ac.uk/ega/ampt2d/propertyreg/1.0/",
"description": "Production server"
}
],
"paths": {
"/phenotypes": {
"get": {
"tags": [
"Phenotype Entity"
],
"summary": "find all phenotypes.",
"description": "Get all phenotypes of Type2Diabetes.",
"operationId": "GetPhenotypeEntity",
"parameters": [
{
"name": "page",
"in": "query",
"description": "Number of pages.",
"schema": {
"type": "string"
}
},
{
"name": "size",
"in": "query",
"description": "size of page.",
"schema": {
"type": "string"
}
},
{
"name": "sort",
"in": "query",
"description": "Ascending or descending.",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK, Successful response",
"content": {
"application/json": {
"schema": {
"title": "Model",
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "generated id of phenotype"
},
"phenotypeGroup": {
"type": "string",
"enum": [
"ANTHROPOMETRIC",
"CARDIOVASCULAR",
"GLYCEMIC"
],
"description": "phenotype group"
},
"description": {
"type": "string",
"description": "description of phenotype"
},
"type": {
"type": "string",
"enum": [
"DICHOTOMOUS",
"MULTICHOTOMOUS"
],
"description": "description of phenotype"
},
"allowedValues": {
"type": "string",
"description": "allowed values of phenotype"
}
}
}
}
}
},
"401": {
"description": "Unauthorized"
},
"403": {
"description": "Forbidden"
},
"404": {
"description": "Not found"
}
}
},
"post": {
"tags": [
"Phenotype Entity"
],
"summary": "save phenotype.",
"description": "Store a phenotype of Type2Diabetes.",
"operationId": "PostPhenotypeEntity",
"requestBody": {
"description": "Store a phenotype of Type2Diabetes.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Phenotype"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "OK, Successful operation",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"links": {
"type": "array",
"items": {
"type": "object",
"properties": {
"href": {
"type": "string"
},
"rel": {
"type": "string"
},
"templated": {
"type": "boolean"
}
}
}
},
"id": {
"type": "string"
},
"phenotypeGroup": {
"type": "string",
"enum": [
"ANTHROPOMETRIC",
"CARDIOVASCULAR",
"GLYCEMIC"
]
},
"description": {
"type": "string"
},
"type": {
"type": "string",
"enum": [
"DICHOTOMOUS",
"MULTICHOTOMOUS"
]
},
"allowedValues": {
"type": "string"
}
}
}
}
}
},
"201": {
"description": "Created"
},
"401": {
"description": "Unauthorized"
},
"403": {
"description": "Forbidden"
},
"404": {
"description": "Not found"
}
}
}
}
},
"components": {
"schemas": {
"Phenotype": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "generated id of phenotype"
},
"phenotypeGroup": {
"type": "string",
"enum": [
"ANTHROPOMETRIC",
"CARDIOVASCULAR",
"GLYCEMIC"
],
"description": "phenotype group"
},
"description": {
"type": "string",
"description": "description of phenotype"
},
"type": {
"type": "string",
"enum": [
"DICHOTOMOUS",
"MULTICHOTOMOUS"
],
"description": "description of phenotype"
},
"allowedValues": {
"type": "string",
"description": "allowed values of phenotype"
}
},
"xml": {
"name": "Phenotype"
}
}
},
"securitySchemes": {
"keycloak_auth": {
"type": "oauth2",
"flows": {
"authorizationCode": {
"tokenUrl": "http://localhost:8080/ega/ampt2d/auth/realms/securemetadata/protocol/openid-connect/token",
"authorizationUrl": "http://localhost:8080/ega/ampt2d/auth/realms/securemetadata/protocol/openid-connect/auth",
"scopes": {
"opened": "openid"
}
}
}
}
}
}
}