# Swagger/OpenAPI support for Mautic API

**URL:** https://forum.mautic.org/t/swagger-openapi-support-for-mautic-api/12565
**Category:** Ideas and Feature Requests
**Created:** [February 3, 2020, 4:38pm UTC](https://forum.mautic.org/t/swagger-openapi-support-for-mautic-api/12565 "2020-02-03T16:38:44Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![dennisameling](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/dennisameling/32/958_2.png) [@dennisameling](https://forum.mautic.org/u/dennisameling)
#### Post date: [February 3, 2020, 4:38pm UTC](https://forum.mautic.org/t/swagger-openapi-support-for-mautic-api/12565/1 "2020-02-03T16:38:44Z")

</div>

**My idea is:**

**UPDATED June 2nd 2020, see [this comment](https://forum.mautic.org/t/swagger-openapi-support-for-mautic-api/12565/7)**

Swagger/OpenAPI would allow the developer API docs to be generated/updated automatically as soon as an API endpoint/model changes, and it will become possible to generate API clients for multiple languages (PHP/Java/JavaScript/etc.). This Symfony bundle might help a lot: [https://symfony.com/doc/current/bundles/NelmioApiDocBundle/index.html](https://symfony.com/doc/current/bundles/NelmioApiDocBundle/index.html)

**I think these groups of people would benefit from this idea:**

People who are using the Mautic API to connect to Mautic instances

**Why I think they would benefit from this idea:**

Improved/more up-to-date API documentation, as well as the possibility to generate API clients (PHP/Java/JavaScript/etc.) on the fly if necessary

**Any code or resources to support this idea:**

[https://swagger.io/docs/specification/about/](https://swagger.io/docs/specification/about/)  
Examples: [https://editor.swagger.io/](https://editor.swagger.io/)

**Are you willing to work on this idea?:**

Yes

**What skills and resources do you need to explore this further?**

Let’s wait for the final version of Mautic 3 before discussing this topic further.

---

<div class="post-metadata">

### Author: ![dennisameling](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/dennisameling/32/958_2.png) [@dennisameling](https://forum.mautic.org/u/dennisameling)
#### Post date: [May 3, 2020, 9:40pm UTC](https://forum.mautic.org/t/swagger-openapi-support-for-mautic-api/12565/2 "2020-05-03T21:40:30Z")

</div>

Did some first work today to enable Swagger on Mautic 3, and it’s going well!

> <https://github.com/dennisameling/mautic/commit/662bb0a5efe65289e923692705f0095a7152d468>

Was able to generate a JSON spec file which has all the endpoints in it:

[https://trello-attachments.s3.amazonaws.com/5dde6d0feb0e5f19e46b96fd/5e4bcfadd30b5f6dd4f4cbd5/b331959cbd6938a773d51c88354bff05/mautic-swagger.json](https://trello-attachments.s3.amazonaws.com/5dde6d0feb0e5f19e46b96fd/5e4bcfadd30b5f6dd4f4cbd5/b331959cbd6938a773d51c88354bff05/mautic-swagger.json)

If you go to [https://editor.swagger.io](https://editor.swagger.io) and upload the JSON file there, you’ll be able to visually see the available endpoints there:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/8/8f8537cfe2a560768182133edaa5cabe047b64af.png)

Next step is to start linking the right data models to all the endpoints. But this is a great first step!! 🎉

---

<div class="post-metadata">

### Author: ![fedy](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/fedy/32/1627_2.png) [@fedy](https://forum.mautic.org/u/fedy)
#### Post date: [May 4, 2020, 9:07am UTC](https://forum.mautic.org/t/swagger-openapi-support-for-mautic-api/12565/3 "2020-05-04T09:07:38Z")

</div>

I have some experience with [https://symfony.com/doc/current/bundles/NelmioApiDocBundle/index.html](https://symfony.com/doc/current/bundles/NelmioApiDocBundle/index.html) and it worked like a charm. For frontend we used great [https://redocly.github.io/redoc/](https://redocly.github.io/redoc/)

---

<div class="post-metadata">

### Author: ![dennisameling](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/dennisameling/32/958_2.png) [@dennisameling](https://forum.mautic.org/u/dennisameling)
#### Post date: [May 4, 2020, 9:21am UTC](https://forum.mautic.org/t/swagger-openapi-support-for-mautic-api/12565/4 "2020-05-04T09:21:18Z")

</div>

Yes I’m using the NelmioApiBundle (see [https://github.com/dennisameling/mautic/commit/662bb0a5efe65289e923692705f0095a7152d468](https://github.com/dennisameling/mautic/commit/662bb0a5efe65289e923692705f0095a7152d468)). I came across ReDoc as well, looks good! Will first need to make sure that the Swagger spec generated by Mautic is as complete as possible, will work a bit more on it during the weekend. Thanks for your input 🙂

---

<div class="post-metadata">

### Author: ![fedy](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/fedy/32/1627_2.png) [@fedy](https://forum.mautic.org/u/fedy)
#### Post date: [May 4, 2020, 9:44am UTC](https://forum.mautic.org/t/swagger-openapi-support-for-mautic-api/12565/5 "2020-05-04T09:44:23Z")

</div>

In some scenarios it is kind of tricky to describe an endpoint via Nelmio annotations to get desired output. If you are stuck, feel free to ask me. I may help you.

---

<div class="post-metadata">

### Author: ![dennisameling](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/dennisameling/32/958_2.png) [@dennisameling](https://forum.mautic.org/u/dennisameling)
#### Post date: [May 10, 2020, 8:49pm UTC](https://forum.mautic.org/t/swagger-openapi-support-for-mautic-api/12565/6 "2020-05-10T20:49:29Z")

</div>

There’s some roadblocks I ran into after spending some hours on researching the internals of both Mautic and the NelmioApiBundle. I have documented them here:

> <https://github.com/mautic/mautic/issues/8780>
>
> This issue is to track technical work on the Feature Request "Swagger/OpenAPI support for Mautic API" from the forums.
> The information below...

@fedy if you’d have some time to look into this as well, that’d be fantastic. I’ll try to spend some time next weekend to to continue diving into this.

---

<div class="post-metadata">

### Author: ![dennisameling](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/dennisameling/32/958_2.png) [@dennisameling](https://forum.mautic.org/u/dennisameling)
#### Post date: [June 2, 2020, 7:31pm UTC](https://forum.mautic.org/t/swagger-openapi-support-for-mautic-api/12565/7 "2020-06-02T19:31:19Z")

</div>

Just had a call with @dongilbert and we’ll try to harmonize efforts for implementing OpenAPI between Acquia and the community, so that we’re all on the same page. We expect to move into the direction of introducing a new API version (v2) using [API Platform](https://api-platform.com/), which will make maintenance a lot easier for all parties involved, make the API more predictable/stable and will help us to automatically generate OpenAPI docs. A migration path from the old API will of course be provided.

We’re trying to get the requirements clear within the next 30 days (roughly) after which we’ll be looking for community contributors to get this project moving forward. If anyone has thoughts on this idea or would like to help, please do not hesitate to leave a comment here! To be continued 🚀

---

<div class="post-metadata">

### Author: ![ash\_s85](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ash_s85/32/691_2.png) [@ash\_s85](https://forum.mautic.org/u/ash_s85)
#### Post date: [September 7, 2020, 7:31pm UTC](https://forum.mautic.org/t/swagger-openapi-support-for-mautic-api/12565/8 "2020-09-07T19:31:46Z")

</div>

Hi,

Is there any news on this? I’m looking to move my clients from Dotmailer to Mautic but my main sticking point at the moment is lack of api sdk’s (primarily java). I’ve had a go generating both a java & spring client with swagger using your json file but it just errors. I’m about to start building a java sdk for my needs but figured I’d see if there was any update on the API-Platform collaboration before I begin.

All the best  
Ash
