Lean JAX-RS Swagger Codegen

This swagger-codegen plugin generates Java interfaces for JAX-RS, which can be used for server AND client alike.

License

License

Categories

Categories

Swagger Program Interface REST Frameworks
GroupId

GroupId

com.github.leanjaxrs
ArtifactId

ArtifactId

jaxrs-lean-swagger-codegen
Last Version

Last Version

0.9
Release Date

Release Date

Type

Type

pom
Description

Description

Lean JAX-RS Swagger Codegen
This swagger-codegen plugin generates Java interfaces for JAX-RS, which can be used for server AND client alike.
Project URL

Project URL

https://github.com/leanjaxrs/swagger-codegen-jaxrs-lean
Project Organization

Project Organization

The Lean JAX RS Project
Source Code Management

Source Code Management

https://github.com/leanjaxrs/swagger-codegen-jaxrs-lean

Download jaxrs-lean-swagger-codegen

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.leanjaxrs/jaxrs-lean-swagger-codegen/ -->
<dependency>
    <groupId>com.github.leanjaxrs</groupId>
    <artifactId>jaxrs-lean-swagger-codegen</artifactId>
    <version>0.9</version>
    <type>pom</type>
</dependency>
// https://jarcasting.com/artifacts/com.github.leanjaxrs/jaxrs-lean-swagger-codegen/
implementation 'com.github.leanjaxrs:jaxrs-lean-swagger-codegen:0.9'
// https://jarcasting.com/artifacts/com.github.leanjaxrs/jaxrs-lean-swagger-codegen/
implementation ("com.github.leanjaxrs:jaxrs-lean-swagger-codegen:0.9")
'com.github.leanjaxrs:jaxrs-lean-swagger-codegen:pom:0.9'
<dependency org="com.github.leanjaxrs" name="jaxrs-lean-swagger-codegen" rev="0.9">
  <artifact name="jaxrs-lean-swagger-codegen" type="pom" />
</dependency>
@Grapes(
@Grab(group='com.github.leanjaxrs', module='jaxrs-lean-swagger-codegen', version='0.9')
)
libraryDependencies += "com.github.leanjaxrs" % "jaxrs-lean-swagger-codegen" % "0.9"
[com.github.leanjaxrs/jaxrs-lean-swagger-codegen "0.9"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

  • jaxrs-lean-swagger-codegen-plugin
  • jaxrs-lean-swagger-codegen-tests

Lean JAX-RS Swagger Codegen Plugin: interfaces without the clutter!

Build Status

Overview

This swagger-codegen plugin generates Java interfaces for JAX-RS, which can be used for server AND client alike.

While Swagger already has built-in plugins claiming to support JAX-RS, these will generate whole maven projects including directory structure, POMs and other files. While this may be a good starting point for some, this approach is problematic when you only need the generated code and nothing else, or if you want to add code generation to your build process. They also generate a plethora of unnecessary dependencies.

In contrast, this plugin will only generate the Java interfaces for the APIs and their respective models, which makes it much smoother to handle.

Features:

  • Generates only Java files and packages, without anything else that makes integration into existing projects harder (no POMs, no directory structures like src/main/..)
  • Generates your API as Java interfaces instead of classes, which will give you more flexibility when implementing them (the base class 'slot' is no longer occupied by Swagger-generated code)
  • Properly represented method return types: While the original JAX-RS codegen plugin only generates API method return types as javax.ws.rs.Response, this plugin will return actual types, making your methods finally type safe. You'll still be able to report HTTP status (404 and the like) by throwing JAX-RS's WebApplicationException
  • Models will use unboxed types (e.g. int instead of Integer) when the property is set to be required. This makes it much clearer to the implementor that such a property can never be null.
  • Generates a neat build() method, allowing fluent initialization of your model classes
  • JavaDoc DocLint-ready: The generated comments will pass DocLint tests

Check out OpenAPI-Spec for additional information about the Swagger project, including additional libraries with support for other languages and more.

How do I use this?

Use this codegen plugin in your maven POM with the swagger-codegen-maven-plugin:

<build>
	<plugins>
		<plugin>
			<groupId>io.swagger</groupId>
			<artifactId>swagger-codegen-maven-plugin</artifactId>
			<version>2.2.1</version>
			
			<!-- bind the jaxrslean swagger-codegen plugin, so the 'jaxrs-lean' language
			becomes available in swagger -->
			<dependencies>
				<dependency>
					<groupId>com.github.upachler.swagger.codegen.jaxrslean</groupId>
					<artifactId>jaxrslean</artifactId>
					<version>1.0-SNAPSHOT</version>
				</dependency>
			</dependencies>
			
			<executions>
				<execution>
					<goals>
						<goal>generate</goal>
					</goals>
					<configuration>
						<inputSpec>${basedir}/src/main/swagger/swagger.yaml</inputSpec>
						<!-- the jaxrs-lean language provided by the jaxrslean codegen plugin -->
						<language>jaxrs-lean</language>

						<apiPackage>com.company.api</apiPackage>
						<modelPackage>com.company.api.model</modelPackage>
						<sourceFolder>${project.build.directory}/generated-sources/swagger</sourceFolder>
					</configuration>
				</execution>
			</executions>

		</plugin>
	</plugins>
</build>

Versions

Version
0.9