gurock / testrail-api

TestRail API: Examples on how to use TestRail's API from various languages
Other
116 stars 87 forks source link

Provide Swagger spec, for generating better clients in many languages #6

Closed ianfixes closed 4 years ago

ianfixes commented 8 years ago

Why?

The API clients that you’ve made available on do indeed work, and your documentation is reasonable. However, for the same effort it takes to write good documentation, you can write a Swagger spec – then you get not only the documentation, but also the ability to code-generate clients whose methods are already declared and whose objects/properties are strongly typed.

What?

At ~1000 lines of Swagger YAML, I’m roughly halfway done writing the entire TestRail spec in Swagger.

Pasting that file into the online Swagger editor will show you the generated documentation and allow you to download a generated client.

Here’s an example of printing out the names of test case types, with the generated Ruby client:

require 'swagger_client'

SwaggerClient.configure do |c|
  c.username = 'my@ema.il'
  c.password = '[one of my TestRail API keys]'
end

client = SwaggerClient::CasesApi.new()
puts "Case types"
client.get_case_types_get().each do |c|
  puts " - " + c.name
end

How?

The only correct way to finish this task would be to host the YAML file for the Swagger spec as a PHP file within the TestRail installation. This is because some parts of the spec are dynamic:

If I finish transcribing the API spec into YAML, can this dynamic functionality be added to the server?

jonridera commented 4 years ago

Closing this issue. If this has been completed and you would like to contribute a custom script, please submit a pull request in the appropriate area here: https://github.com/gurock/testrail-custom

ianfixes commented 4 years ago

The pull request (#8) was that contribution -- a completed implementation of this effort

vbargl commented 1 month ago

Can we reopen this? It seems PR was closed without being merged. Most clients out in the world are slowly getting old and it takes lot of effort to keep them up to date. Easiest solution would be to support OpenAPI / Swagger (or any other) spec that can be used to generate client out of it and therefore simplify efforts to maintain it, not mentioning ability to support vast number of languages.