MRE (минимальный код)
Код: Выделить всё
// ItemDto.java
public record ItemDto(String name, Integer stock) {}
Код: Выделить всё
// ItemsController.java
@RestController
@RequestMapping("/api")
public class ItemsController {
@PostMapping("/items")
public ResponseEntity create(@RequestBody ItemDto dto) {
return ResponseEntity.ok(dto.name() + "-" + dto.stock());
}
}
Код: Выделить всё
// SecurityConfig.java
@Configuration
@EnableWebSecurity
public class SecurityConfig {
@Bean
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// minimal config (this is where I'm stuck)
return http.build();
}
}
POST должен вернуть 200 OK с JSON.
Что я пробовал:
Код: Выделить всё
http.csrf(csrf -> csrf.disable()); // unsure if safe for APIs
permitAll()
Подробнее здесь: https://stackoverflow.com/questions/797 ... om-postman
Мобильная версия