G
G
GuF_20192021-10-13 22:54:42
API
GuF_2019, 2021-10-13 22:54:42

How to generate api client in golang?

I have the following task: I am given a file with the openapi v3 specification, I need to generate code for this specification and, by contacting the server through a certain api method of the generated client, get the information I need. I generated the code using this tool: " https://github.com/OpenAPITools/openapi-generator "
Problems:
1) How to properly create a client using the generated functions? (didn't find a good guide). Also, if it doesn’t bother you, show me how to use secrets when creating a client, because I need to pass host, password and some kind of encrypted client key to it (sorry, I don’t know exactly what kind of key yet)
2) I have this generated code deep in the project, but the generated code also has go.mod. It is not possible to normally import the functions of this generic into the project file I need, it swears by this error - "no required module provides package github/repo_name; to add it:". Would it be a good idea to remove go.mod and use these functions not as a project within a project?
3) If you have not worked with openapi-generator, then tell me the library with which you worked, and tell us how to do the above on this library. If I can't figure it out with mine, I'll try on yours.
Thanks in advance to all those who don't care)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Innokenty Ogoyukin, 2021-10-28
@GuF_2019

For any documentation:
* https://goswagger.io/
* https://eax.me/go-mod/
* https://habr.com/ru/post/421411/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question