'Spring boot call external API with external YAML API definition
I am trying to find way, how to call external API based on YAML definition:
- I have (Spring boot, external) API-1, generated with OpenAPI plugin, which has it's YAML file.
- I have (Spring boot) API-2, which calls API-1. But all I have is YAML definition of API-1.
We know external API can be called with:
@Bean
public WebClient remoteApiBean() {
return WebClient.create("http://example.com/api");
}
And e.g. Service implementation:
@Autowired
public MyService(WebClient remoteApiBean) {
this.remoteApiBean = remoteApiBean;
}
And requesting resource
this.remoteApiBean.get()
.uri("/request")
.retrieve()
.bodyToMono(ModelDTO.class)
.block(REQUEST_TIMEOUT);
API and model info are stored inside of API-1 YAML config. My question is, if it is possible to use API-1 YAML definition as a resource for API-2. Generate code above and also generate DTOs. I think, there MUST be any plugin which generate this, but I am unable to find it, because there are very similar issues with Spring Boot yaml external configurations and google result are bad according this searching.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
