Package io.apicurio.hub.api.codegen
Class OpenApi2JaxRs
- java.lang.Object
-
- io.apicurio.hub.api.codegen.OpenApi2JaxRs
-
- Direct Known Subclasses:
OpenApi2Quarkus,OpenApi2Thorntail
public class OpenApi2JaxRs extends Object
Class used to generate a simple JAX-RS project from an OpenAPI document.- Author:
- eric.wittmann@gmail.com
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classOpenApi2JaxRs.JaxRsRuleFactory
-
Field Summary
Fields Modifier and Type Field Description protected static org.jsonschema2pojo.GenerationConfigconfigprotected io.apicurio.datamodels.core.models.Documentdocumentprotected static com.fasterxml.jackson.databind.ObjectMappermapperprotected static JavaBeanPostProcessorpostProcessorprotected JaxRsProjectSettingssettingsprotected static Charsetutf8
-
Constructor Summary
Constructors Constructor Description OpenApi2JaxRs()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected URIclassnameToUri(String path)ByteArrayOutputStreamgenerate()Generate the JaxRs project.voidgenerate(OutputStream output)Generates a JaxRs project and streams the generated ZIP to the given output stream.protected voidgenerateAll(CodegenInfo info, StringBuilder log, ZipOutputStream zipOutput)Generates all of the content for storage in the ZIP.protected StringgenerateJavaInterface(CodegenInfo info, CodegenJavaInterface _interface)Generates a Jax-rs interface from the given codegen information.protected StringgenerateJaxRsApplication()Generates the JaxRsApplication java class.protected StringgeneratePomXml(CodegenInfo info)Generates the pom.xml file.protected CodegenInfogetInfoFromApiDoc()Processes the OpenAPI document to produce a CodegenInfo object that contains everything needed to generate appropriate Java class(es).protected URLgetResource(String name)protected StringgetResourceName(String name)JaxRsProjectSettingsgetSettings()booleanisUpdateOnly()protected StringjavaPackageToZipPath(String javaPackage)protected StringschemaRefToFQCN(String path)voidsetOpenApiDocument(InputStream stream)Sets the OpenAPI document via an input stream.voidsetOpenApiDocument(String content)Sets the OpenAPI document.voidsetOpenApiDocument(URL url)Sets the OpenAPI document via a URL to the content.voidsetSettings(JaxRsProjectSettings settings)Configure the settings.voidsetUpdateOnly(boolean updateOnly)
-
-
-
Field Detail
-
mapper
protected static com.fasterxml.jackson.databind.ObjectMapper mapper
-
utf8
protected static Charset utf8
-
config
protected static org.jsonschema2pojo.GenerationConfig config
-
postProcessor
protected static JavaBeanPostProcessor postProcessor
-
document
protected transient io.apicurio.datamodels.core.models.Document document
-
settings
protected JaxRsProjectSettings settings
-
-
Method Detail
-
setSettings
public void setSettings(JaxRsProjectSettings settings)
Configure the settings.- Parameters:
settings-
-
setOpenApiDocument
public void setOpenApiDocument(String content)
Sets the OpenAPI document.- Parameters:
content-- Throws:
IOException
-
setOpenApiDocument
public void setOpenApiDocument(URL url) throws IOException
Sets the OpenAPI document via a URL to the content.- Parameters:
url-- Throws:
IOException
-
setOpenApiDocument
public void setOpenApiDocument(InputStream stream) throws IOException
Sets the OpenAPI document via an input stream. The stream must be closed by the caller.- Parameters:
stream-- Throws:
IOException
-
generate
public final void generate(OutputStream output) throws IOException
Generates a JaxRs project and streams the generated ZIP to the given output stream.- Parameters:
output-- Throws:
IOException
-
generateAll
protected void generateAll(CodegenInfo info, StringBuilder log, ZipOutputStream zipOutput) throws IOException
Generates all of the content for storage in the ZIP. Responsible for generating all classes and other resources that make up the generated project.- Parameters:
info-log-zipOutput-- Throws:
IOException
-
generate
public ByteArrayOutputStream generate() throws IOException
Generate the JaxRs project.- Throws:
IOException
-
getInfoFromApiDoc
protected CodegenInfo getInfoFromApiDoc() throws IOException
Processes the OpenAPI document to produce a CodegenInfo object that contains everything needed to generate appropriate Java class(es).- Throws:
IOException
-
generatePomXml
protected String generatePomXml(CodegenInfo info) throws IOException
Generates the pom.xml file.- Parameters:
info-- Throws:
IOException
-
generateJaxRsApplication
protected String generateJaxRsApplication() throws IOException
Generates the JaxRsApplication java class.- Throws:
IOException
-
generateJavaInterface
protected String generateJavaInterface(CodegenInfo info, CodegenJavaInterface _interface)
Generates a Jax-rs interface from the given codegen information.- Parameters:
info-_interface-
-
isUpdateOnly
public boolean isUpdateOnly()
- Returns:
- the updateOnly
-
getSettings
public JaxRsProjectSettings getSettings()
- Returns:
- the settings
-
setUpdateOnly
public void setUpdateOnly(boolean updateOnly)
- Parameters:
updateOnly- the updateOnly to set
-
-