OpenApi Swagger generate Java RestTemplate client - spring

I'm using Openapi 3 to generate java http client.
In my maven plugin configuration, I'm using "resttemplate" :
So I was expecting as a result Spring RestTemplate classes to make HTTP calls.
But in generated sources, I got ApiClient class to handle HTTP calls. ApiClient comes from Jersey library. There's no mention about Spring RestTemplate classes :
Is this normal ?

From the documentation at this link: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/spring.md
Search for the library config option in the big table, and you'll see that the two choices for the library config option are spring-boot or spring-cloud. You're using resttemplate, which is not valid.
(You're using version 5.1.0 of the generator, I'm using 5.0.0, but I'm pretty sure the link I provided applies to both.)

Related

Spring boot -Open api 3 doc generation dynamically without maven and restarting application (swagger Interceptor implementation)

I am using spring boot in which I wanted to dynamically generate open api 3 specification by uploading json/yml and view in swagger ui
upload json/yml
dynamically generate swagger /open api specification
3.view in swagger ui
Is there any approach /plugin available to implement this?
similar implementation as swagger Interceptor but our workstation does not allow to use interceptor. so we are generating our own tool

Spring - How do I annotate properties in classes

I have a Java RESTful client that works create and I use Jackson to de/serialize the returned requests (serialize as XML).
For returned classes I don't need to do anything. For the classes I post (serialize) I use com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
Now with Spring, where the inbound requests can be JSON or XML and the return also can be JSON or XML, do I need to do the equivalent? And if so, what annotation do I use?
Spring pulls in Jackson. But the library it pulls in has com.fasterxml.jackson but not com.fasterxml.jackson.dataformat.
And... I was not aware there were different Jackson libraries. But as there are, which one does Spring use?

using apache camel REST DSL using restlet adding swagger

I am using apache camel REST DSL using springboot. All the configuration works fine. Now I want to add REST documentation using camel swagger java component. The REST DSL and swagger java, works out of the box. I can see the JSON output of the exposed REST services.
Now Question, what steps I need to follow, such that i can view camel REST documentation using swagger-ui?
I searched for answers, however the only solution was to download swagger-ui from github and "copy" <dist> folder to project, this doesn't seems to work, getting 404. URL i am using is localhost:8081\rest\index.html.
I liked the spring-fox swagger2, is it something can be supported in camel?
See this example which includes swagger ui.
https://github.com/apache/camel/tree/master/examples/camel-example-swagger-xml
The index.html file has more details how to access the swagger ui when the application runs.

How to use a Spring Boot enabled library inside a old-school spring server

tl/dr (How) Is it possible to use a jar library, that uses Spring Boot for configuration in a non Spring Boot (regular old-school Spring) server.
We have the problem, that we have a Spring server, that is from the pre-Boot times and we want to create a new library for it. We would like to use Spring Boot in the library (i.e. #EnableAutoConfiguration for configuration). To include the library we have put an spring.xml into the library that enables component-scan inside the library. The classes inside the library use #EnableAutoConfiguration and #EnableWebSecurity to enable configuration and security.
If we include now the library into our server and import the XML file from the library into the server's XML file, only parts of the configuration are working. The #RequestMappings in the library are working and the interfaces are available. However Spring security fails to register it's default filter chain, leading to ugly errors, where the regular Spring Boot config should already work with AnonymousAuthorizationFilter, etc.
We debugged, that the FilterRegistrationBean in spring security is never configured when running that way (and is, if we are running as a Spring Boot application).
So is there a common way how to deal with Spring Boot enabled libraries inside old-school Spring servers?
Is placing a single XML to enable component-scan in the library and importing this XML inside the main server's XML the correct way to include Spring Boot libraries (and how would be the best way, if the server would use Spring Boot itself)?
Does anyone know of the issue with a missing Spring Security filter chain?
PS: I know that we can add the required filters manually. However if we would do that, we would anyway get rid of Spring Boot completely in the library, so this question mainly aims for how to do it with Spring Boot. Of course if it is the wrong way to enable Spring Boot inside a library, please also mention that :-)

Security configuration without XML with custom filters?

I'm using Spring Boot in STS to build a simple REST API.
I have some basic security requirements, similar to the ones described in the original post here: RESTful Authentication via Spring
The accepted answer above seems like a valid solution but does not translate to Spring Boot due to the lack of XML configuration.
How would I configure my Spring Boot application in the same manner?
You can use the same code as in that post if you want (are you sure that's what you want?) with #Configuration. The HttpSecurity builder has methods addFilter(), addFilterBefore(), addFilterAfter(), so you use those instead of the <custom-filter/> element in XML. Most (if not all) XML elements translate pretty directly into Java config.

Resources