Example #1
0
 @Bean
 public Docket petApi() {
   return new Docket(DocumentationType.SWAGGER_2)
       .select()
       .apis(RequestHandlerSelectors.any())
       .paths(PathSelectors.any())
       .build()
       .pathMapping("/")
       .directModelSubstitute(LocalDate.class, String.class)
       .genericModelSubstitutes(ResponseEntity.class)
       .alternateTypeRules(
           newRule(
               typeResolver.resolve(
                   DeferredResult.class,
                   typeResolver.resolve(ResponseEntity.class, WildcardType.class)),
               typeResolver.resolve(WildcardType.class)))
       .useDefaultResponseMessages(false)
       .globalResponseMessage(
           RequestMethod.GET,
           newArrayList(
               new ResponseMessageBuilder()
                   .code(500)
                   .message("500 message")
                   .responseModel(new ModelRef("Error"))
                   .build()));
 }
Example #2
0
  public InferredMapperFactory(ResultSetMapper mapper) {
    this.mapper = mapper;
    ResolvedType rt = tr.resolve(mapper.getClass());
    List<ResolvedType> rs = rt.typeParametersFor(ResultSetMapper.class);
    if (rs.isEmpty() || rs.get(0).getErasedType().equals(Object.class)) {
      throw new UnsupportedOperationException("Must use a concretely typed ResultSetMapper here");
    }

    maps = rs.get(0).getErasedType();
  }
 /**
  * apiDoc.
  *
  * @return a {@link springfox.documentation.spring.web.plugins.Docket} object.
  */
 @Bean
 public Docket apiDoc() {
   return new Docket(DocumentationType.SWAGGER_2)
       .apiInfo(apiInfo())
       .groupName("identity-ui")
       .select()
       .apis(RequestHandlerSelectors.any())
       .paths(PathSelectors.ant("/api/**"))
       .build()
       .pathMapping("/")
       .directModelSubstitute(LocalDate.class, String.class)
       .genericModelSubstitutes(ResponseEntity.class)
       .alternateTypeRules(
           newRule(
               typeResolver.resolve(
                   DeferredResult.class,
                   typeResolver.resolve(ResponseEntity.class, WildcardType.class)),
               typeResolver.resolve(WildcardType.class)))
       .useDefaultResponseMessages(true)
       //                .globalResponseMessage(RequestMethod.GET,
       //                        newArrayList(new ResponseMessageBuilder()
       //                                .code(500)
       //                                .message("500 message")
       //                                .responseModel(new ModelRef("Error"))
       //                                .build()))
       //                .securitySchemes(newArrayList(apiKey()))
       //                .securityContexts(newArrayList(securityContext()))
       //                .enableUrlTemplating(true)
       .globalOperationParameters(
           newArrayList(
               new ParameterBuilder()
                   .name("X-XSRF-TOKEN")
                   .description("CRRF token relay")
                   .modelRef(new ModelRef("string"))
                   .parameterType("header")
                   .required(false)
                   .build()))
   //                .tags(new Tag("Pet Service", "All apis relating to pets"))
   //                .additionalModels(typeResolver.resolve(AdditionalModel.class))
   ;
 }
  private JavaTypeDescriptor makeTypeDescriptor(Name typeName, Class clazz) {
    final JandexPivot jandexPivot = pivotAnnotations(toJandexName(typeName));

    if (clazz.isInterface()) {
      final InterfaceDescriptorImpl typeDescriptor =
          new InterfaceDescriptorImpl(typeName, clazz.getModifiers(), jandexPivot.typeAnnotations);
      typeDescriptorMap.put(typeName, typeDescriptor);

      typeDescriptor.setExtendedInterfaceTypes(extractInterfaces(clazz));

      final ResolvedType resolvedType = classmateTypeResolver.resolve(clazz);
      typeDescriptor.setTypeParameters(extractTypeParameters(resolvedType));
      //			final ResolvedTypeWithMembers resolvedTypeWithMembers = classmateMemberResolver.resolve(
      // resolvedType, null, null );

      typeDescriptor.setFields(extractFields(clazz, typeDescriptor, jandexPivot));
      typeDescriptor.setMethods(extractMethods(clazz, typeDescriptor, jandexPivot));

      return typeDescriptor;
    } else {
      final ClassDescriptorImpl typeDescriptor =
          new ClassDescriptorImpl(
              typeName, clazz.getModifiers(), hasDefaultCtor(clazz), jandexPivot.typeAnnotations);
      typeDescriptorMap.put(typeName, typeDescriptor);

      typeDescriptor.setSuperType(extractSuper(clazz));
      typeDescriptor.setInterfaces(extractInterfaces(clazz));

      final ResolvedType resolvedType = classmateTypeResolver.resolve(clazz);
      typeDescriptor.setTypeParameters(extractTypeParameters(resolvedType));

      typeDescriptor.setFields(extractFields(clazz, typeDescriptor, jandexPivot));
      typeDescriptor.setMethods(extractMethods(clazz, typeDescriptor, jandexPivot));

      return typeDescriptor;
    }
  }