Skip to content
This repository was archived by the owner on Sep 14, 2020. It is now read-only.

Annotation support for springdoc-openapi and querydsl predicate

License

Notifications You must be signed in to change notification settings

gibahjoe/springdoc-param-customizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CircleCI Codecov

Introduction

This is a simple library that is an extension of the Springdoc-Openapi library

This library adds support of the QueryDsl @QuerydslPredicate annotation to Springdoc-Openapi library

It is also very customizable and supports any annotation (ships with @QuerydslPredicate annotation support but more coming later).

Before

Before

After Method 1

Method 1

After Method 2

Method 3

Installation

Add to your build.gradle

allprojects {
    repositories {
	    maven { url 'https://jitpack.io' }
	}
}
dependencies {
    implementation 'com.github.gibahjoe:springdoc-param-customizer:[version]'
}

Usage

There are 2 ways to use this library. Both involve creating a bean in your spring project.

METHOD 1

Registering QuerydslPredicateOperationCustomizer.java as a bean (see below)

@Configuration
public class WebConfiguration implements WebMvcConfigurer {
    //some config
    
    
@Bean
public QuerydslPredicateOperationCustomizer querydslPredicateOperationCustomizer(QuerydslBindingsFactory querydslBindingsFactory) {
   return new QuerydslPredicateOperationCustomizer(querydslBindingsFactory);
}

    //other config    
}
METHOD 2

Using AnnotatedParameterCustomizer.java (a bean that helps to intercept any annotated spring method param for you to customise) and adding the inbuilt DefaultQuerydslPredicateCustomizer. See example below using querydsl customizer

import com.devappliance.springdocparamcustomizer.AnnotatedParameterCustomizer;
import com.devappliance.springdocparamcustomizer.customizerImpl.DefaultQuerydslPredicateCustomizer;

@Configuration
public class WebConfiguration implements WebMvcConfigurer {
    //some config
    
    @Bean
   public AnnotatedParameterCustomizer annotatedParameterCustomizer(Optional<OpenAPI> openAPI, ObjectProvider<EntityPathResolver> resolver) {
       return new AnnotatedParameterCustomizer(openAPI)
                   .addCustomizer(new DefaultQuerydslPredicateCustomizer(new QuerydslBindingsFactory(resolver.getIfAvailable(() -> SimpleEntityPathResolver.INSTANCE))));
   }

    //Ensure to include a bean of your openapi too in your config
    @Bean
    public OpenAPI openApi() {
        return new OpenAPI();
    }

    //other config    
}

The above example uses the inbuilt DefaultQuerydslPredicateCustomizer which displays QueryDslPredicate parameters properly in OpenApi document

Features and bugs

Please file feature requests and bugs at the issue tracker.

About

Annotation support for springdoc-openapi and querydsl predicate

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages