github / rest-api-description

An OpenAPI description for GitHub's REST API
MIT License
1.41k stars 235 forks source link

Client Code Generation Examples #213

Open dmitri-s opened 3 years ago

dmitri-s commented 3 years ago

Perhaps this issue is somewhat off topic. But it seems it would be beneficial to have an example on thow to apply this OpenAPI description.

For example, I am using swagger-codegen 3.0.0 to generate code based on ghes-2.20.yaml and I am running: ./run-in-docker.sh generate -i /gen/modules/ghes-2.20.yaml -l go -o /gen/out/githubapi -DpackageName=githubapi

But I don't know how to replace {protocol} and {hostname} without chaning the values directly in ghes-2.20.yaml file.

I am new to swagger and I am sure there are other poeple who would apreaciate a little guidance.

xuorig commented 3 years ago

Hey @dmitri-s, this will highly depend on your client generation tool. For example https://openapi-generator.tech/docs/usage/ supports a --server-variables option to define those variables. I looked into swagger-codegen and could not find a similar setting. You can also probably change the generated code with your configuration rather than the base YAML file, but both will work.

Good call on adding at least an example though 🙇