com.github.hazard4j:swagger4jsonrpc

This project is implementation of swagger for JSON-RPC with Spring Boot. It generates UI that helps delelopers test api and share it with colleagues

License

License

Categories

Categories

JSON Data Swagger Program Interface REST Frameworks
GroupId

GroupId

com.github.hazard4j
ArtifactId

ArtifactId

swagger4jsonrpc
Last Version

Last Version

0.0.2
Release Date

Release Date

Type

Type

jar
Description

Description

com.github.hazard4j:swagger4jsonrpc
This project is implementation of swagger for JSON-RPC with Spring Boot. It generates UI that helps delelopers test api and share it with colleagues
Project URL

Project URL

https://github.com/hazard4j/swagger
Source Code Management

Source Code Management

http://github.com/hazard4j/swagger/tree/master

Download swagger4jsonrpc

How to add to project

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

Dependencies

compile (6)

Group / Artifact Type Version
org.springframework.boot : spring-boot-starter-web jar
org.apache.commons : commons-lang3 jar 3.4
org.apache.commons : commons-collections4 jar 4.1
io.swagger : swagger-annotations jar 1.5.10
org.projectlombok : lombok jar 1.16.16
com.github.briandilley.jsonrpc4j : jsonrpc4j jar 1.4.6

Project Modules

There are no modules declared in this project.

Swagger 4 JSON-RPC

About

This project is implementation of Swagger for JSON-RPC with usage of jsonrpc4j

Demo project

Find sources of demo project here: https://github.com/haz4j/swagger4jsonrpc-demo

Usage

How to add swagger magic to your typical jsonrpc4j application?

pom.xml: add swagger annotations and swagger4jsonrpc

    <dependencies>
        <!--spring boot, jsonrpc4j, etc-->
        ...

        <!--add this to generate swagger-ui.html page-->
        <dependency>
            <groupId>com.github.haz4j</groupId>
            <artifactId>swagger4jsonrpc</artifactId>
            <version>0.0.3</version>
        </dependency>
    </dependencies>

Configuration: add @EnableSwagger4JsonRpc and bean Docket

@SpringBootApplication
@Configuration
@EnableSwagger4JsonRpc //add this to enable swagger
public class Config {

    //add this to customize swagger 
    @Bean
    public Docket docket(){
        return Docket.builder().build();
    }

    public static void main(String[] args) {
        SpringApplication.run(Config.class, args);
    }

    @Bean
    @Autowired
    public static AutoJsonRpcServiceImplExporter autoJsonRpcServiceImplExporter() {
        return new AutoJsonRpcServiceImplExporter();
    }
}

Interface: add @Api

@JsonRpcService("/v1/api")
@Api(tags = "api", value = "api") //add this to let swagger know that you want to see it
//on swagger-ui page
public interface ApiInterface {
    Integer save(@JsonRpcParam(value = "value") Integer value);
}

Implementation: do nothing :)

@Service
@AutoJsonRpcServiceImpl
public class Impl implements ApiInterface {
    @Override
    public Integer save(Integer value){
        return value;
    }
}

Launch your spring boot app and check out http://app-path/swagger-ui.html

swagger-ui.html

Versions

Version
0.0.2
0.0.1.RELEASE