-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e12553d
commit f61a588
Showing
305 changed files
with
4,579 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* xref:index.adoc[Quarkus - Openapi Generator - Client] |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
docs/modules/ROOT/pages/index.adoc → client/docs/modules/ROOT/pages/index.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
= Quarkus - Openapi Generator | ||
= Quarkus - Openapi Generator - Client | ||
:extension-status: preview | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>quarkus-openapi-generator-parent</artifactId> | ||
<groupId>io.quarkiverse.openapi.generator</groupId> | ||
<version>3.0.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>quarkus-openapi-generator-client-parent</artifactId> | ||
<name>Quarkus - Openapi Generator - Client - Parent</name> | ||
<packaging>pom</packaging> | ||
|
||
<modules> | ||
<module>deployment</module> | ||
<module>runtime</module> | ||
<module>docs</module> | ||
<module>test-utils</module> | ||
</modules> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>quarkus-openapi-generator-server-parent</artifactId> | ||
<groupId>io.quarkiverse.openapi.generator</groupId> | ||
<version>3.0.0-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>quarkus-openapi-generator-server-deployment</artifactId> | ||
<name>Quarkus - Openapi Generator - Server - Deployment</name> | ||
|
||
<dependencies> | ||
<!-- Quarkus --> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-core-deployment</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkiverse.openapi.generator</groupId> | ||
<artifactId>quarkus-openapi-generator-server</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<annotationProcessorPaths> | ||
<path> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-extension-processor</artifactId> | ||
<version>${quarkus.version}</version> | ||
</path> | ||
</annotationProcessorPaths> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
20 changes: 20 additions & 0 deletions
20
...yment/src/main/java/io/quarkiverse/openapi/server/generator/deployment/CodegenConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package io.quarkiverse.openapi.server.generator.deployment; | ||
|
||
import io.quarkus.runtime.annotations.ConfigPhase; | ||
import io.quarkus.runtime.annotations.ConfigRoot; | ||
|
||
@ConfigRoot(name = CodegenConfig.CODEGEN_TIME_CONFIG_PREFIX, phase = ConfigPhase.BUILD_TIME) | ||
public class CodegenConfig { | ||
|
||
static final String CODEGEN_TIME_CONFIG_PREFIX = "quarkus.openapi.generator"; | ||
private static final String CODEGEN_BASE_PACKAGE = CODEGEN_TIME_CONFIG_PREFIX + ".base-package"; | ||
private static final String CODEGEN_SPEC = CODEGEN_TIME_CONFIG_PREFIX + ".spec"; | ||
|
||
public static String getBasePackagePropertyName() { | ||
return CODEGEN_BASE_PACKAGE; | ||
} | ||
|
||
public static String getSpecPropertyName() { | ||
return CODEGEN_SPEC; | ||
} | ||
} |
125 changes: 125 additions & 0 deletions
125
...va/io/quarkiverse/openapi/server/generator/deployment/codegen/ApicurioCodegenWrapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
package io.quarkiverse.openapi.server.generator.deployment.codegen; | ||
|
||
import static io.quarkiverse.openapi.server.generator.deployment.CodegenConfig.getBasePackagePropertyName; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.OutputStream; | ||
import java.nio.file.Path; | ||
import java.util.Enumeration; | ||
import java.util.zip.ZipEntry; | ||
import java.util.zip.ZipFile; | ||
|
||
import org.apache.commons.io.IOUtils; | ||
import org.eclipse.microprofile.config.Config; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import io.apicurio.hub.api.codegen.JaxRsProjectSettings; | ||
import io.apicurio.hub.api.codegen.OpenApi2JaxRs; | ||
import io.quarkus.bootstrap.prebuild.CodeGenException; | ||
|
||
public class ApicurioCodegenWrapper { | ||
|
||
private static final Logger log = LoggerFactory.getLogger(ApicurioCodegenWrapper.class); | ||
private static final String DEFAULT_PACKAGE = "io.apicurio.api"; | ||
|
||
private final File outdir; | ||
private final JaxRsProjectSettings projectSettings; | ||
|
||
public ApicurioCodegenWrapper(Config config, File outdir) { | ||
this(config, outdir, defaultProjectSettings()); | ||
} | ||
|
||
public ApicurioCodegenWrapper(Config config, File outdir, JaxRsProjectSettings projectSettings) { | ||
this.outdir = outdir; | ||
this.projectSettings = projectSettings; | ||
this.projectSettings.setJavaPackage(getBasePackage(config)); | ||
} | ||
|
||
public void generate(Path openApiResource) throws CodeGenException { | ||
final File openApiFile = openApiResource.toFile(); | ||
|
||
log.info("Generating JAX-RS interfaces and beans from: {}", openApiResource); | ||
|
||
if (outdir.isFile()) { | ||
throw new CodeGenException( | ||
"Output directory is unexpectedly a file (should be a directory or non-existent)."); | ||
} | ||
|
||
if (!outdir.exists()) { | ||
outdir.mkdirs(); | ||
} | ||
|
||
// Generate code - output a ZIP file. | ||
File zipFile = new File(outdir, "generated-code.zip"); | ||
|
||
try (FileOutputStream fos = new FileOutputStream(zipFile); | ||
FileInputStream openApiStream = new FileInputStream(openApiFile)) { | ||
OpenApi2JaxRs generator = new OpenApi2JaxRs(); | ||
generator.setSettings(projectSettings); | ||
generator.setUpdateOnly(true); | ||
generator.setOpenApiDocument(openApiStream); | ||
log.info("Generating code..."); | ||
generator.generate(fos); | ||
} catch (Exception e) { | ||
log.error("Error generating code from openapi spec", e); | ||
throw new CodeGenException(e); | ||
} | ||
|
||
// Unpack the temporary ZIP file | ||
log.info("Code generated, unpacking the output ZIP."); | ||
try { | ||
unzip(zipFile, outdir); | ||
} catch (IOException e) { | ||
log.error("Error generating code from openapi spec", e); | ||
throw new CodeGenException(e); | ||
} finally { | ||
// Delete the temporary ZIP file | ||
zipFile.delete(); | ||
} | ||
|
||
log.info("Code successfully generated."); | ||
} | ||
|
||
private void unzip(File fromZipFile, File toOutputDir) throws IOException { | ||
try (java.util.zip.ZipFile zipFile = new ZipFile(fromZipFile)) { | ||
Enumeration<? extends ZipEntry> entries = zipFile.entries(); | ||
while (entries.hasMoreElements()) { | ||
ZipEntry entry = entries.nextElement(); | ||
File entryDestination = new File(toOutputDir, entry.getName()); | ||
if (entry.isDirectory()) { | ||
entryDestination.mkdirs(); | ||
} else { | ||
entryDestination.getParentFile().mkdirs(); | ||
try (InputStream in = zipFile.getInputStream(entry); | ||
OutputStream out = new FileOutputStream(entryDestination)) { | ||
IOUtils.copy(in, out); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
private String getBasePackage(final Config config) { | ||
return config | ||
.getOptionalValue(getBasePackagePropertyName(), String.class) | ||
.orElse(DEFAULT_PACKAGE); | ||
} | ||
|
||
private static JaxRsProjectSettings defaultProjectSettings() { | ||
JaxRsProjectSettings projectSettings = new JaxRsProjectSettings(); | ||
projectSettings.setJavaPackage(DEFAULT_PACKAGE); | ||
|
||
projectSettings.setReactive(false); | ||
projectSettings.setCodeOnly(true); | ||
projectSettings.setCliGenCI(false); | ||
projectSettings.setMavenFileStructure(false); | ||
projectSettings.setIncludeSpec(false); | ||
projectSettings.setCliGenCI(false); | ||
return projectSettings; | ||
} | ||
} |
Oops, something went wrong.