Тёмный

Spring Rest Docs - Documenting REST API | Example | Java Techie 

Java Techie
Подписаться 172 тыс.
Просмотров 29 тыс.
50% 1

This video explain you How to Generate Rest API Documentation using Spring Rest Docs with Test driven approach
#javatechie #springBoot #RestDocs
MockMvc : • Spring Mvc unit test u...
GitHub:
github.com/Java-Techie-jt/spr...
Blogs:
/ javatechie
Facebook:
/ 919464521471923
guys if you like this video please do subscribe now and press the bell icon to not miss any update from Java Techie
Disclaimer/Policy:
--------------------------------
Note : All uploaded content in this channel is mine and its not copied from any community , you are free to use source code from above mentioned GitHub account

Наука

Опубликовано:

 

8 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 30   
@manaspradhan2997
@manaspradhan2997 3 года назад
Very Simple and well explained
@charankumar6942
@charankumar6942 4 года назад
Really very helpfull.. awesome
@nukeshpoodi1409
@nukeshpoodi1409 3 года назад
This is great
@gopald7263
@gopald7263 4 года назад
Awesome
@RaviVerma-bg6ul
@RaviVerma-bg6ul 4 года назад
Awesome thanks
@luckyshanbandara9335
@luckyshanbandara9335 2 года назад
Thank you
@anurag9110
@anurag9110 4 года назад
Actual explanation starts from 07:15.
@utishrajkarnikar9612
@utishrajkarnikar9612 3 года назад
Nice!
@foodgallery5819
@foodgallery5819 3 года назад
Thankyou :)
@AlokKumar-wm1fk
@AlokKumar-wm1fk 2 года назад
Any code for producer side ? how we will do like writing groovy and which creates contract ??
@deveshmishra6611
@deveshmishra6611 4 года назад
Congratulations for 10k subscriber
@Javatechie
@Javatechie 4 года назад
Thanks Devesh 🥰
@aswarthanarayanareddyb176
@aswarthanarayanareddyb176 4 года назад
Really I'm trying to implement in my project since 2 months onwards, thanq java teche, please make video with webTestClint with spring rest docs, advanced Tq
@Javatechie
@Javatechie 4 года назад
Hi Bhupathi, glad to hear this , webtestclient will be same approach instead of mickmvc.perform() we can use this test web client But anyway as I already uploaded this content , If you really need let me know I will share code with you . Wait for Spring Auto Rest Docs 😜, it will be more interesting , you no need to do anything
@aswarthanarayanareddyb176
@aswarthanarayanareddyb176 4 года назад
@@Javatechie please share me code , really tried lot of ways , I'm not succeed with webTestClint , advanced TQ
@Javatechie
@Javatechie 4 года назад
@@aswarthanarayanareddyb176 Will share it tomorrow k
@aswarthanarayanareddyb176
@aswarthanarayanareddyb176 4 года назад
@@Javatechie TQ
@Javatechie
@Javatechie 4 года назад
@@aswarthanarayanareddyb176 just add below piece of code in @BeforeEach annotated method @Autowired private ApplicationContext context; protected WebTestClient webTestClient; @Rule public final JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation(); @Before public void setUp() throws Exception { this.webTestClient = WebTestClient .bindToApplicationContext(context) .apply(springSecurity()) .configureClient() .baseUrl("localhost:8080/") .filter(documentationConfiguration(restDocumentation) .snippets() .withDefaults(WebTestClientInitializer.prepareSnippets(context), CliDocumentation.curlRequest(), HttpDocumentation.httpRequest(), HttpDocumentation.httpResponse(), AutoDocumentation.requestFields(), AutoDocumentation.responseFields(), AutoDocumentation.pathParameters(), AutoDocumentation.requestParameters(), AutoDocumentation.description(), AutoDocumentation.methodAndPath(), AutoDocumentation.section())) .build(); }
@marky6951
@marky6951 2 года назад
Hello, is it possible to document other layers aside controller? for example, I want to generate a document for service layer and other layers. thank you
@sumanthvarada
@sumanthvarada 4 года назад
how to handle multiple codes like 401, 402, 503 etc apart from success respons
@Javatechie
@Javatechie 4 года назад
Either you can return status code from controller using ResponseEntity as return type and set status code Else you can add annotation
@agguLi
@agguLi 4 года назад
This is not the concept of documenting your api with spring rest docs. ( In gerneral with rest api ). Keep in mind that the rest api uses standard status codes and http verbs. Instead of documenting them all, follow the standard like your client will. E.g. If the client wints to create a student with a username that already exists, a 409 should be thrown. That is intuitiv and doesn't need additinal documentation. If you want to document it, do it in you index file e.g. with a hand made table
@Javatechie
@Javatechie 4 года назад
@@agguLi could you please help me to understand purpose of using Spring Rest docs ?
@agguLi
@agguLi 4 года назад
@@Javatechie Spring rest-docs has many advantages e.g. compared with swagger. It is test-driven, so your docs are always correct ( Ofcourse the test are correct ). It is written mark down like( ascii-doc) so you give the client a better api overview of the funcionality with more semantics than just throwing a bunch of url on him. Next, the documentation is decoupled from your implementatino files. If you look at a bigger swagger project, there are many annotations, sometimes more than code. And it leady you to repeat yourself which brings the risk of diverging you api docs from implementation. Another point is, that swagger is heavy. If you scale your api this could be costy. Also, swagger doesn't handle hypermedia ( if this hasn't been included in the last couple of months ). So as you can see, rest docs has a big purpose. If you want to account that I've saif you shouldn't mention every status code, that is because rest with it's http verbs and status codes follows that is already well documented. So there is ne need to document a behaviour that follows an already defined standard. If you have to use some custom exceptions of course you have to define them. Bur rest docs doesn't generate that by default because you should only document the success behaviour of you request.
@oleksandrkovsharov8974
@oleksandrkovsharov8974 2 года назад
Start from 7:16
@rodyatube
@rodyatube 3 года назад
can you share the code used in this video? github ?
@Javatechie
@Javatechie 3 года назад
Source code link mentioned in video description
@Premkumar-ln7gt
@Premkumar-ln7gt 4 года назад
Really very helpfull.. awesome
Далее
spring boot with swagger
31:17
Просмотров 41 тыс.
How to add Swagger to Spring Boot - Brain Bytes
21:09
Просмотров 448 тыс.
Sniper Duel | Standoff 2
00:54
Просмотров 414 тыс.
REST API concepts and examples
8:53
Просмотров 6 млн
Spring Security: Spring Security + REST + JWT
1:52:13
Просмотров 43 тыс.
Spring boot 3 - OpenApi Documentation | Swagger UI
35:09