-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
target/ | ||
.idea/ | ||
*.iml |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
html { | ||
box-sizing: border-box; | ||
overflow: -moz-scrollbars-vertical; | ||
overflow-y: scroll; | ||
} | ||
|
||
*, | ||
*:before, | ||
*:after { | ||
box-sizing: inherit; | ||
} | ||
|
||
body { | ||
margin: 0; | ||
background: #fafafa; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<!doctype html> | ||
<html lang="en-US"> | ||
<head> | ||
<title>Swagger UI: OAuth2 Redirect</title> | ||
</head> | ||
<body> | ||
<script> | ||
'use strict'; | ||
function run () { | ||
var oauth2 = window.opener.swaggerUIRedirectOauth2; | ||
var sentState = oauth2.state; | ||
var redirectUrl = oauth2.redirectUrl; | ||
var isValid, qp, arr; | ||
|
||
if (/code|token|error/.test(window.location.hash)) { | ||
qp = window.location.hash.substring(1).replace('?', '&'); | ||
} else { | ||
qp = location.search.substring(1); | ||
} | ||
|
||
arr = qp.split("&"); | ||
arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=', '":"') + '"';}); | ||
qp = qp ? JSON.parse('{' + arr.join() + '}', | ||
function (key, value) { | ||
return key === "" ? value : decodeURIComponent(value); | ||
} | ||
) : {}; | ||
|
||
isValid = qp.state === sentState; | ||
|
||
if (( | ||
oauth2.auth.schema.get("flow") === "accessCode" || | ||
oauth2.auth.schema.get("flow") === "authorizationCode" || | ||
oauth2.auth.schema.get("flow") === "authorization_code" | ||
) && !oauth2.auth.code) { | ||
if (!isValid) { | ||
oauth2.errCb({ | ||
authId: oauth2.auth.name, | ||
source: "auth", | ||
level: "warning", | ||
message: "Authorization may be unsafe, passed state was changed in server. The passed state wasn't returned from auth server." | ||
}); | ||
} | ||
|
||
if (qp.code) { | ||
delete oauth2.state; | ||
oauth2.auth.code = qp.code; | ||
oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl}); | ||
} else { | ||
let oauthErrorMsg; | ||
if (qp.error) { | ||
oauthErrorMsg = "["+qp.error+"]: " + | ||
(qp.error_description ? qp.error_description+ ". " : "no accessCode received from the server. ") + | ||
(qp.error_uri ? "More info: "+qp.error_uri : ""); | ||
} | ||
|
||
oauth2.errCb({ | ||
authId: oauth2.auth.name, | ||
source: "auth", | ||
level: "error", | ||
message: oauthErrorMsg || "[Authorization failed]: no accessCode received from the server." | ||
}); | ||
} | ||
} else { | ||
oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid, redirectUrl: redirectUrl}); | ||
} | ||
window.close(); | ||
} | ||
|
||
if (document.readyState !== 'loading') { | ||
run(); | ||
} else { | ||
document.addEventListener('DOMContentLoaded', function () { | ||
run(); | ||
}); | ||
} | ||
</script> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
window.onload = function() { | ||
//<editor-fold desc="Changeable Configuration Block"> | ||
|
||
// the following lines will be replaced by docker/configurator, when it runs in a docker-container | ||
window.ui = SwaggerUIBundle({ | ||
url: "src/main/resources/swagger/openapi.yaml", | ||
dom_id: '#swagger-ui', | ||
deepLinking: true, | ||
presets: [ | ||
SwaggerUIBundle.presets.apis, | ||
SwaggerUIStandalonePreset | ||
], | ||
plugins: [ | ||
SwaggerUIBundle.plugins.DownloadUrl | ||
], | ||
layout: "StandaloneLayout" | ||
}); | ||
|
||
//</editor-fold> | ||
}; |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!-- HTML for static distribution bundle build --> | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Swagger UI</title> | ||
<link rel="stylesheet" type="text/css" href="dist/swagger-ui.css" /> | ||
<link rel="stylesheet" type="text/css" href="dist/index.css" /> | ||
<link rel="icon" type="image/png" href="dist/favicon-32x32.png" sizes="32x32" /> | ||
<link rel="icon" type="image/png" href="dist/favicon-16x16.png" sizes="16x16" /> | ||
</head> | ||
|
||
<body> | ||
<div id="swagger-ui"></div> | ||
<script src="dist/swagger-ui-bundle.js" charset="UTF-8"> </script> | ||
<script src="dist/swagger-ui-standalone-preset.js" charset="UTF-8"> </script> | ||
<script src="dist/swagger-initializer.js" charset="UTF-8"> </script> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.mode</groupId> | ||
<artifactId>gh_pages_explr</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<dropwizard.version>4.0.8</dropwizard.version> | ||
<maven.compiler.source>17</maven.compiler.source> | ||
<maven.compiler.target>17</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.dropwizard</groupId> | ||
<artifactId>dropwizard-core</artifactId> | ||
<version>${dropwizard.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.smoketurner</groupId> | ||
<artifactId>dropwizard-swagger</artifactId> | ||
<version>4.0.5-1</version> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>javax.xml.bind</groupId> | ||
<artifactId>jaxb-api</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.swagger.core.v3</groupId> | ||
<artifactId>swagger-jaxrs2</artifactId> | ||
<version>2.2.8</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>jakarta.ws.rs</groupId> | ||
<artifactId>jakarta.ws.rs-api</artifactId> | ||
<version>3.0.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.ws.rs</groupId> | ||
<artifactId>jsr311-api</artifactId> | ||
<version>1.1.1</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.13.0</version> | ||
</plugin> | ||
<plugin> | ||
<groupId>io.swagger.core.v3</groupId> | ||
<artifactId>swagger-maven-plugin</artifactId> | ||
<version>2.2.8</version> | ||
<configuration> | ||
<outputFileName>openapi</outputFileName> | ||
<outputPath>${project.build.sourceDirectory}/../resources/swagger</outputPath> | ||
<outputFormat>JSONANDYAML</outputFormat> | ||
<resourcePackages> | ||
<package>com.mode.example</package> | ||
</resourcePackages> | ||
<prettyPrint>true</prettyPrint> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<phase>compile</phase> | ||
<goals> | ||
<goal>resolve</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.mode.example; | ||
|
||
import io.dropwizard.core.Application; | ||
import io.dropwizard.core.setup.Bootstrap; | ||
import io.dropwizard.core.setup.Environment; | ||
import io.federecio.dropwizard.swagger.SwaggerBundle; | ||
import io.federecio.dropwizard.swagger.SwaggerBundleConfiguration; | ||
import io.swagger.v3.oas.annotations.OpenAPIDefinition; | ||
import io.swagger.v3.oas.annotations.info.Info; | ||
|
||
@OpenAPIDefinition( | ||
info = @Info( | ||
title="GH Pages Explorer API", | ||
version = "1.0.0", | ||
description = "API for GH Pages Explorer") | ||
) | ||
public class App extends Application<AppConfiguration> { | ||
public static void main(String[] args) throws Exception { | ||
new App().run(args); | ||
} | ||
|
||
@Override | ||
public void initialize(Bootstrap<AppConfiguration> bootstrap) { | ||
super.initialize(bootstrap); | ||
bootstrap.addBundle(new SwaggerBundle<>() { | ||
@Override | ||
protected SwaggerBundleConfiguration getSwaggerBundleConfiguration(AppConfiguration appConfiguration) { | ||
return appConfiguration.getSwaggerBundleConfiguration(); | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public void run(AppConfiguration appConfiguration, Environment environment) throws Exception { | ||
environment.jersey().register(new HelloWorldResource()); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.mode.example; | ||
|
||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import io.dropwizard.core.Configuration; | ||
import io.federecio.dropwizard.swagger.SwaggerBundleConfiguration; | ||
|
||
public class AppConfiguration extends Configuration { | ||
@JsonProperty("swagger") | ||
public SwaggerBundleConfiguration swaggerBundleConfiguration; | ||
|
||
public SwaggerBundleConfiguration getSwaggerBundleConfiguration() { | ||
return swaggerBundleConfiguration; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.mode.example; | ||
|
||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.QueryParam; | ||
import jakarta.ws.rs.core.MediaType; | ||
|
||
import java.util.Optional; | ||
|
||
@Path("/hello-world") | ||
@ApiResponse(description = "Hello World Resource", responseCode = "200") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public class HelloWorldResource { | ||
|
||
@GET | ||
public String sayHi(@QueryParam("name") String name) { | ||
return "Hello, %s!".formatted(Optional.ofNullable(name).orElse("world")); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
swagger: | ||
resourcePackage: com.mode.example |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"openapi" : "3.0.1", | ||
"info" : { | ||
"title" : "GH Pages Explorer API", | ||
"description" : "API for GH Pages Explorer", | ||
"version" : "1.0.0" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
openapi: 3.0.1 | ||
info: | ||
title: GH Pages Explorer API | ||
description: API for GH Pages Explorer | ||
version: 1.0.0 |