Open hakontro opened 1 year ago
The closes to an official Python SDK that exists would be the Python client Swagger-codegen could generate for you. Beyond that you would have to make it yourself or use some other code generator that supports Swagger specs.
Found out about the auto-generation from the swagger docs: cool.
Any success in using that with Python? Seems to not be able to correctly get tokens (it fails on decoding the token to some sort of model).. Token is fetched correctly though, maybe just a swagger-codegen issue
Exception has occurred: ValueError
Invalid value for `token`, must not be `None`
File "/code/tripletex-sdk/tripletex/models/employee_token.py", line 236, in token
raise ValueError(
File "/code/tripletex-sdk/tripletex/models/employee_token.py", line 87, in __init__
self.token = token
File "/code/tripletex-sdk/tripletex/api_client.py", line 695, in __deserialize_model
instance = klass(**kwargs)
File "/code/tripletex-sdk/tripletex/api_client.py", line 286, in __deserialize
return self.__deserialize_model(data, klass)
File "/code/tripletex-sdk/tripletex/api_client.py", line 693, in __deserialize_model
kwargs[attr] = self.__deserialize(value, attr_type)
File "/code/tripletex-sdk/tripletex/api_client.py", line 286, in __deserialize
return self.__deserialize_model(data, klass)
File "/code/tripletex-sdk/tripletex/api_client.py", line 693, in __deserialize_model
kwargs[attr] = self.__deserialize(value, attr_type)
File "/code/tripletex-sdk/tripletex/api_client.py", line 286, in __deserialize
return self.__deserialize_model(data, klass)
File "/code/tripletex-sdk/tripletex/api_client.py", line 247, in deserialize
return self.__deserialize(data, response_type)
File "/code/tripletex-sdk/tripletex/api_client.py", line 174, in __call_api
return_data = self.deserialize(response_data, response_type)
File "/code/tripletex-sdk/tripletex/api_client.py", line 343, in call_api
return self.__call_api(
File "/code/tripletex-sdk/tripletex/api/tokensession_api.py", line 150, in token_session_create_create_with_http_info
return self.api_client.call_api(
File "/code/tripletex-sdk/tripletex/api/tokensession_api.py", line 59, in token_session_create_create
(data) = self.token_session_create_create_with_http_info(
File "/code/tripletex-sdk/test/test_invoice.py", line 43, in testInvoice
st = tripletex.TokensessionApi().token_session_create_create(
ValueError: Invalid value for `token`, must not be `None`
Probably a bug in the code generator then, but I will have a look to see if there could be a specification issue. I do doubt it is a specification issue tho as we do use Swagger to generate our own clients for running integration tests with.
Do note that the specification version Tripletex is using is OpenAPI Specification V2 and not V3.
Yeah, have the same feeling. Thanks for having a look, if you want to reproduce: one way to make it fail is to try getting a token
tripletex.TokensessionApi().token_session_create_create(
consumer_token=<c_token>, employee_token=<e_token>, expiration_date="2022-12-10"
)
Hi again!
I think maybe the docs are off. For example, the EmployTooken.token field is marked as required, as is Department.name, but neither are returned from the API (at least not always?).
Could we be misunderstanding something here, or are docs wrong/API has bugs?
Required is only for when you submit said models, it might look a bit weird in some cases and that is due to us using the same model for both incoming and outgoing data.
What fields are returned are controlled by the fields
parameter. The default of fields
in most cases is to include all fields on the first level (*
).
In the case you show here consumerToken
, & employeeToken
are top level fields so they are included but the fields in the model on said fields are not, that is why there is only 2 fields being populated on them (id
& url
). To get the values of employeeToken
in this case then fields
could for example be set to *,employeeToken(*)
Gotcha, that makes sense.
Required is only for when you submit said models
Just trying to understand here: lastName
and firstName
are the only required fields on Employee
according to the docs, but trying to POST /employee
we get an error (brukerType kan ikke være null
). In other words, userType
is also required, right?
Hi.
Great API, congrats.
I've found the Python examples, just wondering if you guys happen to have a Python SDK that you can open source, or if you know if an open source one exists?