openapi - swagger - java project migration to go -gin project

background introduction

In 2018, I started to try to modify the swagger codegen maven plug-in for my own project management. After a simple modification, the plug-in can be used for daily code development. I changed companies twice during the period and was lucky to be recognized by the two units. This model was also recognized during the period. Several enhancements have been made and some plug-ins have been modified to meet the one-click generation of interface documents, and the used ones are still very good. Several cooperative units have used them. I feel very happy that my code has been recognized by most people. . In the past year, I have participated in a very good project, and it has shown its role in it. I have refactored multiple modules of the project over and over again, so that the originally unusable project has gradually been recognized by the market. Although I am only one of the nails, I still feel that my own The team contributed a lot.

 

Recently, I refactored a very complicated logic module. The leader began to ask me to hand over this part of the code to newcomers, and stopped the refactoring of the core module, which made my work very easy, so I decided to pick up my own project, hoping to achieve My own code can seamlessly migrate all interface logic to golang to cope with the cloud-native tide in the future. Comrades who have not used my project provide a follow-up solution. (free...)

--- The problem that is expected to be solved, (swaggercodegen cannot generate multiple files, and cannot control flipping. My own modification solved this problem, but the verification pass of swagger is still not fixed in the process of generating code.)

1, linke multiple swagger files ------" has been resolved. Subsequent projects can still use this mode even if they are generated.

2. Control inversion The go language is not an interpreted language, so I can only achieve control inversion through hard design, --- "The mode has been designed

3. Functional isolation, thanks to the flexibility of func in the go language---"Solved

--- Whether to use swagger go, after a period of use, I found that the code generated by go-swagger is too complicated, and the isolation of functional units cannot be achieved. The code structure is not clear, so I decided to use the gin framework. (Use this to practice first, and then generate other frameworks later)

The hygienic option gin check is flexible and controllable, which is very useful for tags. In the future, I will try to modify the validate part of part of gin and add a new tag to deal with it. My purpose is to collect all source parameters into one place. But this parameter binding verification process will lock the memory

Not sure at the moment, wait until the performance is verified before deciding whether to write or not.

Because the basic structural configuration design has been completed, and the source data yaml has completed all the connection assembly rendering, now we start to implement the details.

Use it here as a diary to record your entire work process and what you need to do in your next blog post.

Find information or source code to find all the keywords and customizations in the binding tag, and complete the arrangement to pave the way for module generation.

Hope to finish this evening --------------------------------------------- ---The dividing line without soul.

 

 

 

 

Guess you like

Origin blog.csdn.net/weixin_40669549/article/details/115254693