ObjectMapper 或 HttpServletRequest 未在默认 AuthApi 接口中配置

问题描述 投票:0回答:1

我创建了应用程序 https://github.com/kulkarnipradnyas/cultfit/tree/main/auth-service 我通过开放的 api maven 插件创建的有效负载和接口

<groupId>io.swagger.codegen.v3</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>${swagger.codegen.maven.plugin.version}</version>

https://github.com/kulkarnipradnyas/cultfit/tree/main/swagger 当我尝试在邮递员上访问我的 /auth/signup 端点时,它发出警告“ObjectMapper 或 HttpServletRequest 未在默认 AuthApi 接口中配置。”它没有让我的端点工作。有人可以帮助我解决所有可能的问题吗?如果已知问题,解决方案是什么。(我是 springboot 的新手)附加生成的接口和我的控制器


@RestController
@Validated
@CrossOrigin("*")
public class AuthController implements AuthApi {

    @Autowired
    private AuthService authService;

    public AuthController() {
    }

    @Override
    @PostMapping("/auth/signIn")
     public   ResponseEntity<Void> signIn(String xCorrelationID,String xRequestID){
        return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED);
    }
    @Override
    @PostMapping("/auth/signup")
    public ResponseEntity<Void> signupUser(@RequestBody User user){
           String token = authService.register(user);
            return new ResponseEntity(token,HttpStatus.OK);
    }
}

生成的 AuthAPI 有以下方法:

  @RequestMapping(
        value = {"/auth/signup"},
        produces = {"application/json"},
        consumes = {"application/json"},
        method = {RequestMethod.POST}
    )
    default ResponseEntity<Void> signupUser(@Parameter(in = ParameterIn.DEFAULT,description = "Create User",required = true,schema = @Schema) @RequestBody @Valid User body) {
        if (!this.getObjectMapper().isPresent() || !this.getAcceptHeader().isPresent()) {
            log.warn("ObjectMapper or HttpServletRequest not configured in default AuthApi interface so no example is generated");
        }

        return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED);
    }
}
ServiceConfig:
@Configuration
@EnableWebSecurity
public class SecurityConfig extends  
   WebSecurityConfigurerAdapter {  
 it has below method
@Override
 protected void configure(HttpSecurity http) throws Exception {
    http.csrf().disable()
            .authorizeHttpRequests((authorize) ->
                    //authorize.anyRequest().authenticated()
                    authorize
                            .antMatchers(HttpMethod.POST, 
        "/auth/signup").permitAll()
                             .antMatchers(HttpMethod.POST, 
      "/auth/signIn").permitAll()
                            .anyRequest().authenticated()

            ) .exceptionHandling(exception -> 
  exception.authenticationEntryPoint(authenticationEntryPoint))
            .sessionManagement(session -> 
  session.sessionCreationPolicy 
      (SessionCreationPolicy.STATELESS));

}
java spring-boot maven-plugin
1个回答
0
投票

我已经使来自 intelijj 的缓存失效,它开始工作。它通过在已实现接口中编写的默认方法抛出警告。 如果有人遇到以下问题,请检查以下几点: 1.在pom.xml中正确导入模块 2.添加新模块后下载maven依赖。 3.接口中写的名称和参数应该与控制器中覆盖方法相同。

© www.soinside.com 2019 - 2024. All rights reserved.