Skip to content

Commit

Permalink
0.1.8rc7 - get resource file as stream of openapi schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
mehillid committed Jun 27, 2024
1 parent 3a4c445 commit 009ddc2
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 32 deletions.
18 changes: 9 additions & 9 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Make sure you include the <a href="https://jitpack.io/">repository</a> as well.
<dependency>
<groupId>com.github.qlsolutions.JavalinFly</groupId>
<artifactId>javalinfly-core</artifactId>
<version>0.1.8rc6</version>
<version>0.1.8rc7</version>
</dependency>
```

Expand All @@ -37,7 +37,7 @@ Make sure you include the <a href="https://jitpack.io/">repository</a> as well.
<annotationProcessorPath>
<groupId>com.github.qlsolutions.JavalinFly</groupId>
<artifactId>javalinfly-core</artifactId>
<version>0.1.8rc6</version>
<version>0.1.8rc7</version>
</annotationProcessorPath>
</annotationProcessorPaths>
</configuration>
Expand All @@ -51,7 +51,7 @@ Make sure you include the <a href="https://jitpack.io/">repository</a> as well.
<dependency>
<groupId>com.github.qlsolutions.JavalinFly</groupId>
<artifactId>javalinfly-kotlin</artifactId>
<version>0.1.8rc6</version>
<version>0.1.8rc7</version>
</dependency>
```

Expand All @@ -69,20 +69,20 @@ Make sure you include the <a href="https://jitpack.io/">repository</a> as well.
- Dependency

```groovy
implementation 'com.github.qlsolutions.JavalinFly:javalinfly-core:0.1.8rc6'
implementation 'com.github.qlsolutions.JavalinFly:javalinfly-core:0.1.8rc7'
```

- Annotation processor

```groovy
annotationProcessor 'com.github.qlsolutions.JavalinFly:javalinfly-core:0.1.8rc6'
annotationProcessor 'com.github.qlsolutions.JavalinFly:javalinfly-core:0.1.8rc7'
```

- <details>
<summary>Optionally also the kotlin module</summary>

```groovy
implementation 'com.github.qlsolutions.JavalinFly:javalinfly-kotlin:0.1.8rc6'
implementation 'com.github.qlsolutions.JavalinFly:javalinfly-kotlin:0.1.8rc7'
```

</details>
Expand All @@ -93,19 +93,19 @@ Make sure you include the <a href="https://jitpack.io/">repository</a> as well.

- Dependency
```groovy
implementation("com.github.qlsolutions.JavalinFly:javalinfly-core:0.1.8rc6")
implementation("com.github.qlsolutions.JavalinFly:javalinfly-core:0.1.8rc7")
```

- Annotation processor
```groovy
annotationProcessor("com.github.qlsolutions.JavalinFly:javalinfly-core:0.1.8rc6")
annotationProcessor("com.github.qlsolutions.JavalinFly:javalinfly-core:0.1.8rc7")
```

- <details>
<summary>Optionally also the kotlin module</summary>

```groovy
implementation("com.github.qlsolutions.JavalinFly:javalinfly-kotlin:0.1.8rc6")
implementation("com.github.qlsolutions.JavalinFly:javalinfly-kotlin:0.1.8rc7")
```

</details>
Expand Down
28 changes: 27 additions & 1 deletion javalinfly-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.github.unldenis</groupId>
<artifactId>JavalinFly</artifactId>
<version>0.1.8rc6</version>
<version>0.1.8rc7</version>
</parent>

<artifactId>javalinfly-core</artifactId>
Expand All @@ -31,8 +31,34 @@
<artifactId>jackson-databind</artifactId>
<version>2.15.2</version>
</dependency>

<dependency>
<groupId>com.goterl</groupId>
<artifactId>resource-loader</artifactId>
<version>2.0.2</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<minimizeJar>true</minimizeJar>
</configuration>
</plugin>
</plugins>
</build>
<!-- <build>-->
<!-- <plugins>-->
<!-- <plugin>-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class Vars {


public static String openApiSpec() {
return SwaggerUIHtmlGenerator.readResourceFile("/" + RESOURCE_FILE_SPEC);
return SwaggerUIHtmlGenerator.readResourceFile(RESOURCE_FILE_SPEC);
}

private static String SWAGGER_UI = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
package com.quicklink.javalinfly.openapi;


import com.goterl.resourceloader.FileLoader;
import com.quicklink.javalinfly.JavalinFly;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.net.URISyntaxException;
import java.nio.file.Files;

public class SwaggerUIHtmlGenerator {

public static String readResourceFile(String fileName) {
InputStream inputStream = ClassLoader.getSystemClassLoader().getResourceAsStream(fileName);
if (inputStream == null) {
throw new IllegalArgumentException("File not found: " + fileName);
}
try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {
StringBuilder content = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
content.append(line).append("\n");
}
return content.toString();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
try {
var file = FileLoader.get().load(fileName, JavalinFly.class);
return Files.readString(file.toPath());
} catch (IOException e) {
throw new UncheckedIOException(e);
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}

public static String generateSwaggerUIHtml(String openApiJson) {
Expand Down
2 changes: 1 addition & 1 deletion javalinfly-example-kotlin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.github.unldenis</groupId>
<artifactId>JavalinFly</artifactId>
<version>0.1.8rc6</version>
<version>0.1.8rc7</version>
</parent>

<artifactId>javalinfly-example-kotlin</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion javalinfly-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.github.unldenis</groupId>
<artifactId>JavalinFly</artifactId>
<version>0.1.8rc6</version>
<version>0.1.8rc7</version>
</parent>

<artifactId>javalinfly-example</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion javalinfly-kotlin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.github.unldenis</groupId>
<artifactId>JavalinFly</artifactId>
<version>0.1.8rc6</version>
<version>0.1.8rc7</version>
</parent>

<artifactId>javalinfly-kotlin</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.github.unldenis</groupId>
<artifactId>JavalinFly</artifactId>
<version>0.1.8rc6</version>
<version>0.1.8rc7</version>
<packaging>pom</packaging>

<modules>
Expand Down

0 comments on commit 009ddc2

Please sign in to comment.