When you have an OpenAPI documentation, you know how to build your requests and how to parse responses. Swagger can help you speed up that process by generating a client package that wraps the calls for you.
chuckNorris_openAPI-v2.yaml
" file.operationId
" attribute, it will be used to name the methods in the client library. This attribute is not required. If you omit it, the generator will name the method using a combination of the path and
the HTTP operation, such as "get_random"for instance.
tags
" attribute. It will be used to name the client library. If you omit it, the library will be called "DefaultApi".unzip ~/Downloads/python-client-generated.zip
docs
folder contains the documentation for the 3 generated classes that you will use:ChuckNorrisApi
: offers the get_categories_list
, get_joke
and get_jokes_with_string
methodsJokeObject
: exposes the attributes of a joke: categories
, created_at
, icon_url
, id
, updated_at
, url
and value
.InlineResponse200
: response type of a search request, exposes the attributes total
and result
(of type list of JokeObject). Note: the name InlineResponse200 is not great, it is a known issue :-(retext ~/Downloads/docs/ChuckNorrisApi.md
.)
python -m venv environment_name
) or create a new project with PyCharm.source environment_location/bin/activate
(replace environment_location with the appropriate path), your terminal should now prepend your environment name to your command prompt), move to the directory where you've unzipped the generated client library and run python setup.py install --user --install-lib environment_location/lib/python3.8/site-packages/
and pip install -r requirements.txt