Using Swagger definition to generate REST client for Jama
[Deleted User]
Posts: 3
Dear Community,
Looking at what Swagger is, it turned out that it is not only a standard way to describe REST APIs, but it has also powerful tools to automatically generate handy client libraries for many different languages (Swagger Codegen).
It turns out that you can download the definition of the interface directly from the JAMA server, run Swagger codegen and start using your nicely (python in my case) REST client.
Well... mostly.
I found two issues:
======================
(1) The security definitions are missing, therefore the basic auth step is missing:
Please add:
"securityDefinitions": {
"basicAuth": {
"type": "basic",
"description": "HTTP Basic Authentication."
}
},
at the top of the defnition (maybe prior to the "definitions" tag) and
also list the security at every endpoint like in:
"paths" : {
"/items/{id}/lock" : {
"get" : {
"security": [
{
"basicAuth": []
}
],
"description" : "",
....
}
See i.e.:
https://github.com/swagger-api/swagger-editor/issues/556
requests/36280 Jama Security definitions
Kind regards
Hauke
Looking at what Swagger is, it turned out that it is not only a standard way to describe REST APIs, but it has also powerful tools to automatically generate handy client libraries for many different languages (Swagger Codegen).
It turns out that you can download the definition of the interface directly from the JAMA server, run Swagger codegen and start using your nicely (python in my case) REST client.
Well... mostly.
I found two issues:
======================
(1) The security definitions are missing, therefore the basic auth step is missing:
Please add:
"securityDefinitions": {
"basicAuth": {
"type": "basic",
"description": "HTTP Basic Authentication."
}
},
at the top of the defnition (maybe prior to the "definitions" tag) and
also list the security at every endpoint like in:
"paths" : {
"/items/{id}/lock" : {
"get" : {
"security": [
{
"basicAuth": []
}
],
"description" : "",
....
}
See i.e.:
https://github.com/swagger-api/swagger-editor/issues/556
requests/36280 Jama Security definitions
======================
(2) Another problem is that the swagger description defines i.e.
List[Project] as the return type of the getProjects service, but the
jama server returns the actual List[Project] in the "data" sub-element
of the response. So the deserialisation does not work with any swagger-
codegen generated client.
So the response object definition must consider this for all endpoint
definitions.
======================
Kind regards
Hauke
0