Swagger JAXB

XJC Plugin to add Swagger Annotations to your swagger generated JAXB classes, see github for info

License

License

Categories

Categories

Swagger Program Interface REST Frameworks
GroupId

GroupId

hu.icellmobilsoft.jaxb
ArtifactId

ArtifactId

swagger-jaxb
Last Version

Last Version

1.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

Swagger JAXB
XJC Plugin to add Swagger Annotations to your swagger generated JAXB classes, see github for info
Project URL

Project URL

https://github.com/icellmobilsoft/swagger-jaxb
Project Organization

Project Organization

i-Cell Mobilsoft Zrt.
Source Code Management

Source Code Management

https://github.com/icellmobilsoft/swagger-jaxb

Download swagger-jaxb

How to add to project

<!-- https://jarcasting.com/artifacts/hu.icellmobilsoft.jaxb/swagger-jaxb/ -->
<dependency>
    <groupId>hu.icellmobilsoft.jaxb</groupId>
    <artifactId>swagger-jaxb</artifactId>
    <version>1.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/hu.icellmobilsoft.jaxb/swagger-jaxb/
implementation 'hu.icellmobilsoft.jaxb:swagger-jaxb:1.1.0'
// https://jarcasting.com/artifacts/hu.icellmobilsoft.jaxb/swagger-jaxb/
implementation ("hu.icellmobilsoft.jaxb:swagger-jaxb:1.1.0")
'hu.icellmobilsoft.jaxb:swagger-jaxb:jar:1.1.0'
<dependency org="hu.icellmobilsoft.jaxb" name="swagger-jaxb" rev="1.1.0">
  <artifact name="swagger-jaxb" type="jar" />
</dependency>
@Grapes(
@Grab(group='hu.icellmobilsoft.jaxb', module='swagger-jaxb', version='1.1.0')
)
libraryDependencies += "hu.icellmobilsoft.jaxb" % "swagger-jaxb" % "1.1.0"
[hu.icellmobilsoft.jaxb/swagger-jaxb "1.1.0"]

Dependencies

compile (7)

Group / Artifact Type Version
io.swagger : swagger-annotations jar 1.5.12
javax.xml.parsers : jaxp-api jar 1.4.5
com.sun.xml.parsers : jaxp-ri jar 1.4.5
com.sun.xml.bind : jaxb-core jar 2.2.11
com.sun.xml.bind : jaxb-xjc jar 2.2.11
com.sun.xml.bind : jaxb-impl jar 2.2.11
javax.xml.bind : jaxb-api jar 2.2.12

test (2)

Group / Artifact Type Version
junit : junit jar 4.12
org.mockito : mockito-all jar 1.10.19

Project Modules

There are no modules declared in this project.

swagger-jaxb

It was created form be.redlab.jaxb:swagger-jaxb, since the original GitHub project seems abandoned, this fork is developed independently from its parents.

The modification is based on the following fork: https://github.com/peneksglazami/swagger-jaxb

Summary

This project is a refactored version of the forks mentioned above, its purpose was to make the project more extendable, namely allowing to override the generated annotations and their targets.

Maven central

This project is available in maven central as:

    <dependency>
        <groupId>hu.icellmobilsoft.jaxb</groupId>
        <artifactId>swagger-jaxb</artifactId>
        <version>1.1.0</version>
    </dependency>

Original README

swagger-jaxb

JAXB XJC Plugin for automatically adding annotations from Swagger to generated classes from an XSD

Tests run in separate project, see here for the code https://github.com/redlab/swagger-jaxb-tck

Usage

  • REQUIRE Java 8 or higher!

  • build the plugin with maven

  • install it in your local repo

  • add the plugin to your classpath and use -swaggify on your jaxb command line or configure it i your pom or

  • add sonatype snapshot repository to your repo manager. ( post an issue if you really want dev version in Maven Central )

Use with org.jvnet.jaxb2.maven2 maven-jaxb2-plugin
 <build>
     <plugins>
         <plugin>
             <groupId>org.jvnet.jaxb2.maven2</groupId>
             <artifactId>maven-jaxb2-plugin</artifactId>
             <version>0.13.2</version>
             <executions>
                 <execution>
                     <goals>
                         <goal>generate</goal>
                     </goals>
                 </execution>
             </executions>
             <configuration>
                 <schemaIncludes>
                     <schemaInclude>**/*.xsd</schemaInclude>
                 </schemaIncludes>
                 <strict>true</strict>
                 <verbose>true</verbose>
                 <extension>true</extension>
                 <removeOldOutput>true</removeOldOutput>
                 <args>
                     <arguments>-swaggerify</arguments>
                 </args>
                 <plugins>
                     <plugin>
                         <groupId>be.redlab.jaxb</groupId>
                         <artifactId>swagger-jaxb</artifactId>
                         <version>1.5</version>
                     </plugin>
                 </plugins>
                 <dependencies>
                     <dependency>
                         <groupId>io.swagger</groupId>
                         <artifactId>swagger-annotations</artifactId>
                         <version>1.5.12</version>
                     </dependency>
                 </dependencies>
             </configuration>
         </plugin>
     </plugins>
 </build>
 <dependencies>
     <dependency>
         <groupId>io.swagger</groupId>
         <artifactId>swagger-annotations</artifactId>
         <version>1.5.12</version>
     </dependency>
 </dependencies>
Use with org.codehaus.mojo jaxb2-maven-plugin
<build>
<pluginManagement>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxb2-maven-plugin</artifactId>
            <version>2.3</version>
            <dependencies>
                <dependency>
                    <groupId>be.redlab.jaxb</groupId>
                    <artifactId>swagger-jaxb</artifactId>
                    <version>1.5</version>
                </dependency>
                <dependency>
                    <groupId>javax.xml.parsers</groupId>
                    <artifactId>jaxp-api</artifactId>
                    <version>1.4.5</version>
                </dependency>
                <dependency>
                    <groupId>com.sun.xml.parsers</groupId>
                    <artifactId>jaxp-ri</artifactId>
                    <version>1.4.5</version>
                </dependency>
                <dependency>
                    <groupId>com.sun.xml.bind</groupId>
                    <artifactId>jaxb-xjc</artifactId>
                    <version>2.2.11</version>
                </dependency>
                <dependency>
                    <groupId>com.sun.xml.bind</groupId>
                    <artifactId>jaxb-core</artifactId>
                    <version>2.2.11</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</pluginManagement>
<plugins>
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>jaxb2-maven-plugin</artifactId>
        <version>2.3</version>
        <executions>
                <execution>
                    <id>internal.generate</id>
                    <goals>
                        <goal>xjc</goal>
                    </goals>
                    <configuration>
                        <arguments>-swaggerify</arguments>
                        <clearOutputDir>true</clearOutputDir>
                        <packageName>be.redlab.jaxb.swagger.generated.model</packageName>
                        <sources>
                            <source>${project.basedir}/src/main/xsd/schema</source>
                        </sources>
                    </configuration>
                </execution>
        </executions>
    </plugin>
</plugins>

<dependencies>
    <dependency>
        <groupId>io.swagger</groupId>
        <artifactId>swagger-annotations</artifactId>
        <version>1.5.12</version>
    </dependency>
</dependencies>

Also you can use plugin with Gradle

configurations {
    xjcConf
}

dependencies {
    xjcConf 'com.sun.xml.bind:jaxb-xjc:2.2.6'
    xjcConf 'com.sun.xml.bind:jaxb-impl:2.2.6'
    xjcConf 'javax.xml.bind:jaxb-api:2.2.6'
    xjcConf 'org.jvnet.jaxb2_commons:jaxb2-basics:1.11.1'
    xjcConf 'org.jvnet.jaxb2_commons:jaxb2-basics-runtime:1.11.1'
    xjcConf 'org.jvnet.jaxb2_commons:jaxb2-basics-tools:1.11.1'
    xjcConf 'org.jvnet.jaxb2_commons:jaxb2-basics-ant:1.11.1'
    xjcConf 'org.jvnet.jaxb2_commons:jaxb2-basics-annotate:1.0.3'

    xjcConf('be.redlab.jaxb:swagger-jaxb:1.5') {
        exclude group: 'com.sun.xml.bind'
        exclude group: 'javax.xml.bind'
    }

}

task generateClassesFromXsd {
 doLast {
    ant.taskdef(
        name: 'antXjc',
        classname: 'org.jvnet.jaxb2_commons.xjc.XJC2Task',
        classpath: configurations.xjcConf.asPath
    )

    System.setProperty('javax.xml.accessExternalSchema', 'file')

    ant.antXjc(
            destdir: 'src/main/java',
            binding: 'src/main/resources/xsd/binding.xjb',
            extension: 'true') {
        arg(value: '-swaggerify')
        schema(dir: 'src/main/resources/xsd') {
            include(name: '*.xsd')
        }
    }
}


}
hu.icellmobilsoft.jaxb

icellmobilsoft

Versions

Version
1.1.0
1.0.1