Videos
Check out our tutorial video series.
Creating SDK Libraries with MailSlurp's OpenAPI and Swagger Codegen: A Step-by-Step Guide to Generating Code in Your Language of Choice.
MailSlurp's REST API has built in Swagger/OpenAPI support. That means MailSlurp provides an API specification file from which you can generate code libraries in the languages of your choice. This article will explain how MailSlurp describes their API and how you can use the resulting with
.
To generate code with Swagger you need a description of an API. This description should be in the OpenAPI/Swagger format. The format is basically a way of listing every HTTP endpoint in an API and the requests and responses expected.
The MailSlurp swagger definition is a JSON object with the following structure:
The paths object contains a description of all the API endpoints available. The descriptions will be used later to generate method signatures in API client code. Each path key looks a bit like this:
Notice in the responses field their is a return object definition . This reference is used to generate model classes for request and response payloads in the generate code.
Once you have a swagger spec for a given API you can use the swagger-codegen cli to generate a library in the language of your choice for interacting with said API.
The results will be a folder containing a generated Java library for calling the MailSlurp API with fully typed requests, responses, and methods.
Check out our tutorial video series.
Email and SMS guides for automation and testing.
View github project code for multiple languages.
Latest posts from the MailSlurp team.
Test, build, and automate messaging with a free MailSlurp account.