smtp4dev icon indicating copy to clipboard operation
smtp4dev copied to clipboard

[Feature] Make the API public and document it

Open lmexo opened this issue 2 years ago • 3 comments

I wanted to integrate this awesome tool in end-to-end testing using docker and there I would love to have an API, A openapi spec would be awesome! Currently the routes and types must be manually derived by inspecting the source code, which is cumbersome :/

Often a openapi generator can easily be integrated 🚀

lmexo avatar Jan 25 '23 08:01 lmexo

I was in the exact same situation and found this: https://github.com/gessnerfl/fake-smtp-server which is actually maintained to date and has an interface and swagger API documentation.

ahmed2m avatar Feb 18 '24 23:02 ahmed2m

I am open to this in future, but have resisted making the API public until now because I wanted to be able to change it freely without having to think about versioning.

Instead of hosting a complete application like SMTP4DEV, you might consider using an SMTP server component directly in your automated tests. SMTP4DEV uses Rnwood.SmtpServer and if you use .NET you can use this:

Example here: https://github.com/rnwood/smtpserver/blob/master/Rnwood.SmtpServer.Tests/ClientTests.cs

This should be much simpler and more robust than starting up an app in separate process. Similar libraries exist in other ecosystems if you're not on .NET.

rnwood avatar Feb 25 '24 12:02 rnwood

@rnwood It's just more convenient when writing the tests locally rather within actual test suite, we're testing email contents not the functionality of an smtp itself so it would just be easier to use the same smtp4dev docker service that is used in development for testing using the API, it's language/backend agnostic solution. It's both easier since we can see the emails being sent during tests so that we can inspect them etc.. & we can screenshot the email contents in an end to end test.

And I think the project is mature enough now for an API documentation, if for any reason you'd be changing things drastically it would be a major version change.

Would appreciate this small change since there are some useful features here I'm missing in the other project I mentioned above like the unread indicator and socket connection.

ahmed2m avatar Feb 28 '24 10:02 ahmed2m

Work has begun on this in #1376

rnwood avatar Apr 11 '24 19:04 rnwood

This is merged and available. To get started, click ... button in the header and then "API".

rnwood avatar Apr 22 '24 09:04 rnwood