Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

integration with OpenAPI #662

Open
rssdev10 opened this issue Aug 2, 2023 · 5 comments
Open

integration with OpenAPI #662

rssdev10 opened this issue Aug 2, 2023 · 5 comments

Comments

@rssdev10
Copy link

rssdev10 commented Aug 2, 2023

OpenAPI is a common way to describe API specification both for server and clients. The package https://github.com/JuliaComputing/OpenAPI.jl as well as https://openapi-generator.tech/docs/generators/julia-server/ provides a server code generation with data structures both for requests and responses. And, the code provides data parsing, validation and serializing of the results.

But OpenAPI.jl doesn't provide any functionality for authentication, CORS, routing and logging. These parts of the code should be implemented manually. See the example - https://github.com/OpenSesame/GptSearchPlugin/blob/main/src/server.jl or https://github.com/JuliaComputing/OpenAPI.jl/blob/main/test/server/petstore_v3/petstore_server.jl

It would be good to have a way to reuse components of Genie to have an easy way to write web services based on external OpenAPI specification.

@essenciary
Copy link
Member

That's a great idea, thanks! Are you familiar with the OpenAPI.jl package (as I'm not). Could you help with this?

@rssdev10
Copy link
Author

rssdev10 commented Aug 3, 2023

Hi, yes, we are working with OpenAPI.jl.

E.g. there is the specification - https://github.com/OpenSesame/GptSearchPlugin/blob/main/resources/dev-openai/.well-known/openapi.yaml

openapi-generator can be installed by different ways - https://openapi-generator.tech/docs/installation/ or be used directly as a openapi-generator-cli java-jar file from https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/.

And, there is a script for generating the code:
https://github.com/OpenSesame/GptSearchPlugin/blob/main/scripts/openapi_generator.sh

For this generated code some additional methods should be implemented. E.g. in our sample, these methods are mentioned here - https://github.com/OpenSesame/GptSearchPlugin/blob/main/src/generated/src/GptPluginServer.jl#L8-L16

And, the routes should be registered: https://github.com/OpenSesame/GptSearchPlugin/blob/main/src/generated/src/GptPluginServer.jl#L32-L51

As a result, we created https://github.com/OpenSesame/GptSearchPlugin/blob/main/src/server.jl

The service entry point in our case is https://github.com/OpenSesame/GptSearchPlugin/blob/main/ws_run.jl

More general examples are available at https://github.com/JuliaComputing/OpenAPI.jl/tree/main/test/server
And I think @tanmaykm, who is the author of OpenAPI.jl, can also comment on it.

@essenciary
Copy link
Member

Thank you for the details @rssdev10 - very helpful!

@rssdev10
Copy link
Author

rssdev10 commented Aug 3, 2023

Actually I see two scenarios here:

  1. Keep the generated with OpenAPI code as is. And implement a service with components based on Genie (routing, security, logging).
  2. Implement new templates for code generation based on the code https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator/src/main/resources/julia-server . But in this case the question will be - how to keep consistent the Julia code in general for generating and validating data structures. It would be really good to have the only version of this code.

@tanmaykm
Copy link

tanmaykm commented Aug 4, 2023

Thanks for initiating this. It will be great to have OpenAPI and Genie work together. I am yet to go through the details, but am happy to pitch in wherever needed.

@essenciary essenciary self-assigned this Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants