-
Notifications
You must be signed in to change notification settings - Fork 6
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
KTOR-7748 Generate a server project from OpenAPI specification #34
base: main
Are you sure you want to change the base?
Conversation
@antonarhipov, could you also check? |
@vnikolova, please check the docs |
@Stexxe, thanks for the PR. |
b389707
to
4987a45
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! A few grammar and punctuation edits in my comments.
I tried this: anton@macbook-pro tmp % ./ktor-cli/ktor openapi -o ktor-project openapi.yml anton@macbook-pro tmp % less /Users/anton/.ktor/run.log: 2024/11/22 18:25:34 16: fetch OpenAPI JAR: unexpected response status 404 from the server: <title>404 - Path /org/openapitools/openapi-generator-cli/7.10.0-SNAPSHOT/openapi-generator-cli-7.10.0-20241106.082455-66.jar not found in local storage of repository "Snapshots" [id=snapshots]</title> ... |
That's strange. I cannot reproduce it at the moment. Can you please try again? |
Co-authored-by: Vik Nikolova <[email protected]>
Co-authored-by: Vik Nikolova <[email protected]>
Co-authored-by: Vik Nikolova <[email protected]>
Co-authored-by: Vik Nikolova <[email protected]>
Co-authored-by: Vik Nikolova <[email protected]>
Co-authored-by: Vik Nikolova <[email protected]>
Co-authored-by: Vik Nikolova <[email protected]>
Co-authored-by: Vik Nikolova <[email protected]>
f87d1fe
to
54b5ea0
Compare
DialContext: func(_ context.Context, network, addr string) (net.Conn, error) { | ||
return net.DialTimeout(network, addr, 5*time.Second) | ||
}, | ||
TLSHandshakeTimeout: 10 * time.Second, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please consider extracting constants
return e | ||
} | ||
|
||
return "https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.10.0/openapi-generator-cli-7.10.0.jar" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we might also want to have a property for version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by property?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
env variable. URL is hard to use to change just version
https://youtrack.jetbrains.com/issue/KTOR-7748
How to use
Generates a server project using the given OpenAPI specification.
To generate the project, issue the following command in the current working directory:
To generate the project in a different directory, use the
-o
or--output
flag:How it works
It downloads a JAR with the OpenAPI CLI Generator utility, saves it into a temp directory, and then executes it as an external command to generate a project. To execute the external command, it tries to find a JDK and downloads one if it cannot be found.
The downloaded JAR is cached in the
~/.ktor/temp
directory forever until the version of the OpenAPI generator is changed in the source code.Here is a list of issues related to the generated code: