Skip to content

Commit 2668929

Browse files
authored
javalinGH-47 Cleanup modules (javalin#50)
* javalinGH-48 Make javalin-openapi-plugin a dependency of swagger & redoc plugins javalin#48 * javalinGH-47 Cleanup modules
1 parent 253b6c6 commit 2668929

File tree

26 files changed

+484
-130
lines changed

26 files changed

+484
-130
lines changed

build.gradle.kts

+46-43
Original file line numberDiff line numberDiff line change
@@ -19,58 +19,61 @@ allprojects {
1919
maven("https://maven.reposilite.com/snapshots")
2020
}
2121

22-
publishing {
23-
repositories {
24-
maven {
25-
name = "reposilite-repository"
26-
url = uri("https://maven.reposilite.com/${if (version.toString().endsWith("-SNAPSHOT")) "snapshots" else "releases"}")
27-
28-
credentials {
29-
username = getEnvOrProperty("MAVEN_NAME", "mavenUser")
30-
password = getEnvOrProperty("MAVEN_TOKEN", "mavenPassword")
31-
}
32-
}
33-
}
34-
}
22+
description
23+
?.takeIf { it.isNotEmpty() }
24+
?.split("|")
25+
?.let { (projectName, projectDescription) ->
26+
publishing {
27+
publications {
28+
create<MavenPublication>("library") {
29+
pom {
30+
name.set(projectName)
31+
description.set(projectDescription)
32+
url.set("https://github.com/javalin/javalin-openapi")
33+
34+
licenses {
35+
license {
36+
name.set("The Apache License, Version 2.0")
37+
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
38+
}
39+
}
40+
developers {
41+
developer {
42+
id.set("dzikoysk")
43+
name.set("dzikoysk")
44+
email.set("[email protected]")
45+
}
46+
}
47+
scm {
48+
connection.set("scm:git:git://github.com/javalin/javalin-openapi.git")
49+
developerConnection.set("scm:git:ssh://github.com/javalin/javalin-openapi.git")
50+
url.set("https://github.com/javalin/javalin-openapi.git")
51+
}
52+
}
3553

36-
publishing {
37-
publications {
38-
create<MavenPublication>("library") {
39-
from(components.getByName("java"))
54+
from(components.getByName("java"))
55+
}
56+
}
4057

41-
pom {
42-
name.set("Javalin OpenAPI Plugin")
43-
description.set("Compile-time OpenAPI integration for Javalin 5.x")
44-
url.set("https://github.com/javalin/javalin-openapi")
58+
repositories {
59+
maven {
60+
name = "reposilite-repository"
61+
url = uri("https://maven.reposilite.com/${if (version.toString().endsWith("-SNAPSHOT")) "snapshots" else "releases"}")
4562

46-
licenses {
47-
license {
48-
name.set("The Apache License, Version 2.0")
49-
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
63+
credentials {
64+
username = getEnvOrProperty("MAVEN_NAME", "mavenUser")
65+
password = getEnvOrProperty("MAVEN_TOKEN", "mavenPassword")
5066
}
5167
}
52-
developers {
53-
developer {
54-
id.set("dzikoysk")
55-
name.set("dzikoysk")
56-
email.set("[email protected]")
57-
}
58-
}
59-
scm {
60-
connection.set("scm:git:git://github.com/javalin/javalin-openapi.git")
61-
developerConnection.set("scm:git:ssh://github.com/javalin/javalin-openapi.git")
62-
url.set("https://github.com/javalin/javalin-openapi.git")
63-
}
6468
}
6569
}
66-
}
67-
}
6870

69-
signing {
70-
if (findProperty("signing.keyId") != null) {
71-
sign(publishing.publications.getByName("library"))
71+
signing {
72+
if (findProperty("signing.keyId") != null) {
73+
sign(publishing.publications.getByName("library"))
74+
}
75+
}
7276
}
73-
}
7477

7578
java {
7679
withJavadocJar()

examples/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Examples
2+
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
sourceSets.getByName("main") {
2+
java.srcDir("src/main/kotlin")
3+
}
4+
15
dependencies {
26
// declare lombok annotation processor as first
37
val lombok = "1.18.24"
@@ -8,15 +12,15 @@ dependencies {
812

913
// then openapi annotation processor
1014
annotationProcessor(project(":openapi-annotation-processor"))
11-
implementation(project(":javalin-openapi-plugin"))
12-
implementation(project(":javalin-swagger-plugin"))
13-
implementation(project(":javalin-redoc-plugin"))
15+
implementation(project(":javalin-plugins:javalin-openapi-plugin"))
16+
implementation(project(":javalin-plugins:javalin-swagger-plugin"))
17+
implementation(project(":javalin-plugins:javalin-redoc-plugin"))
1418

15-
implementation("io.javalin:javalin:5.0.0-SNAPSHOT")
16-
implementation("com.fasterxml.jackson.core:jackson-databind:2.13.3")
19+
implementation("io.javalin:javalin:5.0.1")
20+
implementation("com.fasterxml.jackson.core:jackson-databind:2.14.0-rc1")
1721

18-
val logback = "1.3.0-alpha16"
22+
val logback = "1.4.3"
1923
implementation("ch.qos.logback:logback-core:$logback")
2024
implementation("ch.qos.logback:logback-classic:$logback")
21-
implementation("org.slf4j:slf4j-api:2.0.0-alpha7")
25+
implementation("org.slf4j:slf4j-api:2.0.3")
2226
}

openapi-test/src/main/java/io/javalin/openapi/plugin/test/JavalinTest.java renamed to examples/javalin-gradle-kotlin/src/main/java/io/javalin/openapi/plugin/test/JavalinTest.java

+69-68
Original file line numberDiff line numberDiff line change
@@ -107,34 +107,34 @@ public static void main(String[] args) {
107107
openApiConfiguration.setDocumentationPath(deprecatedDocsPath); // by default it's /openapi
108108
// Based on official example: https://swagger.io/docs/specification/authentication/oauth2/
109109
openApiConfiguration.setSecurity(new SecurityConfiguration(
110-
Map.ofEntries(
111-
entry("BasicAuth", new BasicAuth()),
112-
entry("BearerAuth", new BearerAuth()),
113-
entry("ApiKeyAuth", new ApiKeyAuth()),
114-
entry("CookieAuth", new CookieAuth("JSESSIONID")),
115-
entry("OpenID", new OpenID("https://example.com/.well-known/openid-configuration")),
116-
entry("OAuth2", new OAuth2(
117-
"This API uses OAuth 2 with the implicit grant flow.",
118-
List.of(
119-
new ImplicitFlow(
120-
"https://api.example.com/oauth2/authorize",
121-
new HashMap<>() {{
122-
put("read_pets", "read your pets");
123-
put("write_pets", "modify pets in your account");
124-
}}
125-
)
126-
)
127-
))
128-
),
129-
List.of(
130-
new Security(
131-
"oauth2",
132-
List.of(
133-
"write_pets",
134-
"read_pets"
135-
)
110+
Map.ofEntries(
111+
entry("BasicAuth", new BasicAuth()),
112+
entry("BearerAuth", new BearerAuth()),
113+
entry("ApiKeyAuth", new ApiKeyAuth()),
114+
entry("CookieAuth", new CookieAuth("JSESSIONID")),
115+
entry("OpenID", new OpenID("https://example.com/.well-known/openid-configuration")),
116+
entry("OAuth2", new OAuth2(
117+
"This API uses OAuth 2 with the implicit grant flow.",
118+
List.of(
119+
new ImplicitFlow(
120+
"https://api.example.com/oauth2/authorize",
121+
new HashMap<>() {{
122+
put("read_pets", "read your pets");
123+
put("write_pets", "modify pets in your account");
124+
}}
136125
)
126+
)
127+
))
128+
),
129+
List.of(
130+
new Security(
131+
"oauth2",
132+
List.of(
133+
"write_pets",
134+
"read_pets"
135+
)
137136
)
137+
)
138138
));
139139
openApiConfiguration.setDocumentProcessor(docs -> { // you can add whatever you want to this document using your favourite json api
140140
docs.set("test", new TextNode("Value"));
@@ -157,49 +157,50 @@ public static void main(String[] args) {
157157

158158
@Override
159159
@OpenApi(
160-
path = ROUTE,
161-
operationId = "cli",
162-
methods = HttpMethod.POST,
163-
summary = "Remote command execution",
164-
description = "Execute command using POST request. The commands are the same as in the console and can be listed using the 'help' command.",
165-
tags = { "Cli" },
166-
security = {
167-
@OpenApiSecurity(name = "BasicAuth")
168-
},
169-
requestBody = @OpenApiRequestBody(
170-
content = {
171-
@OpenApiContent(from = String.class), // simple type
172-
@OpenApiContent(from = EntityDto[].class), // array
173-
@OpenApiContent(from = LombokEntity.class), // lombok
174-
@OpenApiContent(mimeType = "image/png", type = "string", format = "base64"), // single file upload,
175-
@OpenApiContent(mimeType = "multipart/form-data", properties = {
176-
@OpenApiContentProperty(name = "form-element", type = "integer"), // random element in form-data
177-
@OpenApiContentProperty(name = "file-name", isArray = true, type = "string", format = "base64") // multi-file upload
178-
})
179-
}
180-
),
181-
headers = {
182-
//@OpenApiParam(name = "Authorization", description = "Alias and token provided as basic auth credentials", required = true, type = UUID.class),
183-
@OpenApiParam(name = "Optional"),
184-
@OpenApiParam(name = "X-Rick", example = "Rolled"),
185-
@OpenApiParam(name = "X-SomeNumber", required = true, type = Integer.class, example = "500")
186-
},
187-
pathParams = {
188-
@OpenApiParam(name = "name", description = "Name", required = true, type = UUID.class)
189-
},
190-
responses = {
191-
@OpenApiResponse(status = "200", description = "Status of the executed command", content = {
192-
@OpenApiContent(from = EntityDto[].class)
193-
}),
194-
@OpenApiResponse(
195-
status = "400",
196-
description = "Error message related to the invalid command format (0 < command length < " + 10 + ")",
197-
content = @OpenApiContent(from = EntityDto[].class)
198-
),
199-
@OpenApiResponse(status = "401", description = "Error message related to the unauthorized access", content = {
200-
@OpenApiContent(from = EntityDto[].class)
201-
})
160+
path = ROUTE,
161+
operationId = "cli",
162+
methods = HttpMethod.POST,
163+
summary = "Remote command execution",
164+
description = "Execute command using POST request. The commands are the same as in the console and can be listed using the 'help' command.",
165+
tags = { "Cli" },
166+
security = {
167+
@OpenApiSecurity(name = "BasicAuth")
168+
},
169+
requestBody = @OpenApiRequestBody(
170+
content = {
171+
@OpenApiContent(from = String.class), // simple type
172+
@OpenApiContent(from = EntityDto[].class), // array
173+
@OpenApiContent(from = LombokEntity.class), // lombok
174+
@OpenApiContent(from = KotlinEntity.class), // kotlin
175+
@OpenApiContent(mimeType = "image/png", type = "string", format = "base64"), // single file upload,
176+
@OpenApiContent(mimeType = "multipart/form-data", properties = {
177+
@OpenApiContentProperty(name = "form-element", type = "integer"), // random element in form-data
178+
@OpenApiContentProperty(name = "file-name", isArray = true, type = "string", format = "base64") // multi-file upload
179+
})
202180
}
181+
),
182+
headers = {
183+
//@OpenApiParam(name = "Authorization", description = "Alias and token provided as basic auth credentials", required = true, type = UUID.class),
184+
@OpenApiParam(name = "Optional"),
185+
@OpenApiParam(name = "X-Rick", example = "Rolled"),
186+
@OpenApiParam(name = "X-SomeNumber", required = true, type = Integer.class, example = "500")
187+
},
188+
pathParams = {
189+
@OpenApiParam(name = "name", description = "Name", required = true, type = UUID.class)
190+
},
191+
responses = {
192+
@OpenApiResponse(status = "200", description = "Status of the executed command", content = {
193+
@OpenApiContent(from = EntityDto[].class)
194+
}),
195+
@OpenApiResponse(
196+
status = "400",
197+
description = "Error message related to the invalid command format (0 < command length < " + 10 + ")",
198+
content = @OpenApiContent(from = EntityDto[].class)
199+
),
200+
@OpenApiResponse(status = "401", description = "Error message related to the unauthorized access", content = {
201+
@OpenApiContent(from = EntityDto[].class)
202+
})
203+
}
203204
)
204205
public void handle(@NotNull Context ctx) { }
205206

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package io.javalin.openapi.plugin.test
2+
3+
data class KotlinEntity(
4+
val name: String,
5+
val value: Int
6+
)

openapi-test/pom.xml renamed to examples/javalin-maven-java/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<dependency>
2929
<groupId>io.javalin</groupId>
3030
<artifactId>javalin</artifactId>
31-
<version>5.0.0-SNAPSHOT</version>
31+
<version>5.0.1</version>
3232
</dependency>
3333
<dependency>
3434
<groupId>org.tinylog</groupId>
@@ -85,7 +85,7 @@
8585
<annotationProcessorPath>
8686
<groupId>io.javalin-rfc</groupId>
8787
<artifactId>openapi-annotation-processor</artifactId>
88-
<version>1.1.7</version>
88+
<version>5.0.1</version>
8989
</annotationProcessorPath>
9090
</annotationProcessorPaths>
9191
</configuration>

0 commit comments

Comments
 (0)