Need to change GET mapping name on Swagger UI - spring-boot

I am working with Java Spring Boot Application.
My Current GET method in RestController is below .
GetMapping on RestController
After launching my swagger looks like below
Swgger UI
Is there any way, i can still use "/v1/person" in Controller , but on swagger i only want to display "/person".
I don't want "/v1/person" on swagger

Firstly, It is not possible to do that.
I think you are looking at it completely wrong. Swagger is meant to be like a contract that you expose to the client(who ever is calling your API). This should have details about what the endpoint is all about, how a client can call your endpoint, with what arguments and what the client can expect in return.
If you use /v1/person in your controller, that means it can only be called with url http://......./v1/person.
Now if you (somehow) display /person in Swagger, then the client cannot call your endpoint and the basic idea of Swagger is destroyed.
Hope its clear.

Related

How will swagger work with spring boot if there is no rest controller, no request mapping annotation?

In my service there are only POJOs present but I don't need any controller to send them from any API, I just want to make a swagger documentation but they say there is no way to make swagger without the rest controller. Is there any way?
Generally swagger is used for documenting REST api but still you tweak it. Hope you are looking to generate schema/ dtos

mimic swagger api on spring boot application

I got a Spring boot REST based proxy server application with standard REST End point exposed(GET, POST,PUT and DELETE) to outside world.
Any requests coming from external world then will be routed to actual functionality internally.
Now the requirement is to expose all the API supported by my REST proxy server. As I mentioned I do not have static controller path in my code for individual APIs. So would like to get your input how to create swagger support for all the internal APIs that my proxy server support. Is there are a way I can generate swagger schema manually to mimics the controller path? Or is there any other way to solve this problem?
Thanks in advance.

how to make spring mvc functions available for rest calls

I have a spring mvc application which runs correctly,now another colleague wants to call the same functions from another application but he needs REST URL of my functions.
how is it possible to provide the same functionality through spring REST?
is it just with new annotations .please provide some resource to show me how to do it.
when server has a service, only legal clients which had any contracts with server can access it. And clients can use service by the way such as: use RestTemplate to get/post request to URL of service, and clients can get data as JSON, or XML type if you have an equivalent object as this image:
Also, a service can be support as a interface, ex: google search is a service supported by google, but it's not rest service.
If you know each other URL address you can consume each other REST API from java code by using RestTemplate object.
I would advise you to go over the Spring starter guide which deals with that issue, here is the link (Consuming a RESTful Web Service):
https://spring.io/guides/gs/consuming-rest/

Emails in restful spring Get request url

I am having a problem with passing emails in http url using spring. My url looks as follows
http://localhost:8080/users/{email}
I am using spring mvc to handle this GET request.
Using my browser url bar or using Postman when I do the following
http://localhost:8080/users/sampleEmail#gmail.com
I only see sampleEmail#gmail in the spring controller code. For some reason the ".com" part is stripped out. Would anyone know if I am doing something wrong? Thanks
It is because Spring truncates whatever is coming after DOT(.) assuming it to be an extension.
Refer this:
Spring MVC #PathVariable with dot (.) is getting truncated
Is there a requirement that you need to use only GET? If not then switch to POST and send JSON Object with required parameters such as {email: "abc#xyz.com"}

Spring Boot REST JSP

I have a working Spring BOOT application that has a custom security provider and REST API controllers. I would also like to add a GUI interface to the application for access from a browser through jsps, html, and a login page which uses my existing custom security provider I used with the REST APIs. Maybe using Spring MVC since that is needed for the REST API support. I could not find a single example of doing this on the web. Also, I do NOT want to use any web XML based configuration files - as I am currently only using Java config for the implementation of the REST APIs. I am also currently using SSL for REST API access through SSL in a Jetty embedded web container. Please help if you can? Thanks in advanced.
Paul there is a rather large amount of information on view technologies that are compatible with Spring BOOT. You need to decide what you want to use and do relevant research for it.
As a guiding hand here check this page out for just one of the many types:
http://kielczewski.eu/2014/04/spring-boot-mvc-application/
You may follow this procedure :
lets assume that u have an endpoint for which you need both REST and view controllers,your REST endpoint exposes your data in JSON as RESTController and your view Endpoint returns the view name as Simple old controller.
lets say your base url is at localhost:8080 and your endpoint of interest is /students
you could have both in same application but at different endpoints like this :
REST : localhost:8080/api/v1/students -- exposes json
VIEW : localhost:8080/students -- returns a view
hope this make clear ..

Resources