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 SDK 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/java-client-generated.zip
docs
folder contains the documentation for the 3 generated classes that you will use:ChuckNorrisApi
: offers the getCategoriesList
, getJoke
and getJokesWithString
methodsJokeObject
: exposes the attributes of a joke: categories
, createdAt
, iconUrl
, id
, updatedAt
, 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
.)
pom.xml
file and add the following dependency in the dependencies section:mvn clean install
pom.xml
file and add the following dependency (as explained in the README.md):