mirror of
https://github.com/axllent/mailpit.git
synced 2026-04-26 08:45:54 +03:00
[GH-ISSUE #188] Swagger file #123
Labels
No labels
awaiting feedback
bug
docker
documentation
enhancement
github_actions
invalid
pull-request
question
stale
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/mailpit#123
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @swimmwatch on GitHub (Oct 14, 2023).
Original GitHub issue: https://github.com/axllent/mailpit/issues/188
Hi! Thanks for awesome alternative to MailHog project.
Can you please tell me swagger file was generated or written manually?
@axllent commented on GitHub (Oct 14, 2023):
Thanks for the kind words @swimmwatch.
The swagger file is automatically generated using "go swagger", which uses inline code comments to gather the info. Why do you ask?
@swimmwatch commented on GitHub (Oct 14, 2023):
Currently i am working on Python SDK for Mailpit REST API. I generated SDK using OpenAPI Generator and it printed some errors:
For example:
-attribute paths.'/api/v1/tags'(put).operationId is repeatederror occurs becauseGET /api/v1/tagsendpoint has duplicatedoperationIdvalue -SetTags. I think it should be equalGetAllTagsor something like that.I think it would be cool to add validation of the generated
swagger.jsonfile at the CI level.@swimmwatch commented on GitHub (Oct 14, 2023):
I also found out that the description
HTMLResponsedata type is missing in generatedswagger.jsonfile:Because of this, the generator thinks that the response body should be empty. But that's not true.
I think specification should be like that:
@axllent commented on GitHub (Oct 14, 2023):
I'll look into this soon, although I don't personally use swagger so I may require some help. I must admit that the bundled API documentation (which uses the swagger file) has been pretty great though.
@swimmwatch commented on GitHub (Oct 14, 2023):
Thanks, I will help as much as I can.
@axllent commented on GitHub (Oct 15, 2023):
@swimmwatch I have made a number of changes which I believe fixes the errors and response data. Would you mind please checking out the
feature/swaggerbranch and testing the swagger.json for me? Thanks@swimmwatch commented on GitHub (Oct 15, 2023):
Ok, I will check.
@swimmwatch commented on GitHub (Oct 15, 2023):
@adiabatic i have ran utility
openapi-generator-cliwithvalidateoption:Old specification:
Fixed specification:
All issues was fixed.
I have checked generated SDK:
GET /view/{ID}.html- OkGET /view/{ID}.txt- OkGET /api/v1/message/{ID}/part/{PartID}- Invalid data type forBinaryResponse: need specify that it is binary data.GET /api/v1/message/{ID}/headers- OkGET /api/v1/message/{ID}- OkGET /api/v1/message/{ID}/raw- OkGET /api/v1/message/{ID}/part/{PartID}/thumb- same problem asGET /api/v1/message/{ID}/part/{PartID}POST /api/v1/message/{ID}/release- I don't understand what this method does. Can you explain please?PUT /api/v1/tags- Ok.GET /api/v1/tags- Ok.GET /api/v1/messages- OkPUT /api/v1/messages- OkDELETE /api/v1/messages- OkDELETE /api/v1/search- OkGET /api/v1/search- OkGET /api/v1/info- OkGET /api/v1/webui- OkGET /api/v1/message/{ID}/link-check- OkGET /api/v1/message/{ID}/html-check- Ok@axllent commented on GitHub (Oct 15, 2023):
Yay, thanks for releasing testing! I've also added a validation test to prevent this happening in future, and I will merge this in tomorrow (my time) and release a new version 👍
@axllent commented on GitHub (Oct 16, 2023):
Sorry, I missed your questions...
The binary file - the closest I can get to this is documented here which isn't exactly what you're after, but I think the only solution available.
There does not appear to be any way to define
"format": "binary". I've just made the change to the feature branch mentioned earlier (if you have time to test this within the next couple of hours?), however I need to get a new Mailpit release out soon to address another issue so if I don't hear from you then I will just include the changes so far (including the BinaryResponse) and we can come back to this later.POST /api/v1/message/{ID}/release- this is documented in the API as "Release a message via a pre-configured external SMTP server. This is only enabled if message relaying has been configured." and relates to the (SMTP relay)[https://github.com/axllent/mailpit/wiki/SMTP-relay] functionality. It is only enabled if the SMTP relay is configured. Do you need any more information about this?@axllent commented on GitHub (Oct 16, 2023):
The link I provided earlier won't work any more as this has now been merged into
developand released with v1.9.8. As I mentioned before, I'm not sure whether theBinaryResponse"solution" I provided actually helps or potentially makes things worse for you, but please let me know either way.@swimmwatch commented on GitHub (Oct 16, 2023):
@axllent sorry i couldn't answer because of work.
Unfortunately the latest version
swagger.jsondoesn't work forBinaryResponse.Can you please tell me how to generate the swagger file yourself? I want to try something from Google.
POST /api/v1/message/{ID}/release- Ok. Thanks.@axllent commented on GitHub (Oct 17, 2023):
I'll try keep this as simple as possible. I don't know what architecture or platform you're on, so I'll assume Linux amd64.
Here's the swagger binary (for go-swagger): swagger.tar.gz
From within the root directory of Mailpit:
./swagger generate spec -m -i ./server/apiv1/swagger-config.yml -o ./server/ui/api/v1/swagger.json@axllent commented on GitHub (Oct 28, 2023):
Did you get anywhere with a potential solution for this @swimmwatch ?
@swimmwatch commented on GitHub (Oct 28, 2023):
@axllent hi!
Sorry for my delay.
I have run this program on my PC (Ubuntu 20.04):
Can you send me command that uses Docker please?
@axllent commented on GitHub (Oct 29, 2023):
@swimmwatch Sorry about that. I've created a very basic docker image which should work - unfortunately it's very slow as it takes about a minute here to generate the docs as it also needs to compile Mailpit in the background. The image is also pretty large as go-swagger requires go to be installed too.
You can run this within the project folder:
@swimmwatch commented on GitHub (Oct 29, 2023):
@axllent thank you for command!
Unfortunately, this command generates empty
swagger.jsonfile:Can you please tell me what could be causing this? I have run this within the project folder.
@axllent commented on GitHub (Oct 30, 2023):
Oh shit, I'm so sorry - there was a typo in my original command:
I had a space instead of a
-in theswagger-config.ymlpart. This should definitely work now.@swimmwatch commented on GitHub (Nov 5, 2023):
@axllent hi! Thanks for command fix. I have tried to generate properly
swagger.jsonbut unfortunately i can't find valid type forBinaryResponse.I think this issue can be closed. The most important thing is that I wanted to suggest to use swagger validation. Thank you for help.
I hope that in the future I will be able to offer something useful for this project.
@axllent commented on GitHub (Nov 6, 2023):
@swimmwatch I feared that would be the case (that you also wouldn't find a solution to that). Considering this is the case, I think it may be better I change it back to
"type": "string"for the sake of the API documentation as it also doesn't understand the "new format" (my attempt at making it binary as per the instructions I followed). What do you think, is the original string OK?The upside is there is now automatic validation, so thanks for your suggestion and help there.