Class 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
    • Field Detail

      • mapper

        protected static com.fasterxml.jackson.databind.ObjectMapper mapper
      • utf8

        protected static Charset utf8
      • config

        protected static org.jsonschema2pojo.GenerationConfig config
      • document

        protected transient io.apicurio.datamodels.core.models.Document document
    • Constructor Detail

      • OpenApi2JaxRs

        public OpenApi2JaxRs()
        Constructor.
    • 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
      • 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
      • 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 -
      • getResource

        protected URL getResource​(String name)
      • getResourceName

        protected String getResourceName​(String name)
      • classnameToUri

        protected URI classnameToUri​(String path)
      • schemaRefToFQCN

        protected String schemaRefToFQCN​(String path)
      • javaPackageToZipPath

        protected String javaPackageToZipPath​(String javaPackage)
      • isUpdateOnly

        public boolean isUpdateOnly()
        Returns:
        the updateOnly
      • setUpdateOnly

        public void setUpdateOnly​(boolean updateOnly)
        Parameters:
        updateOnly - the updateOnly to set