-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
String Example Value #1140
Comments
Not sure why do you want to implement rfc822 over HTTP but you should try the following type Message struct {
Subject string `example:"Test mail"`
Body string `example:"Message"`
}
// @consume json
// @Param email body Message true "Json Payload" |
A Content-Type of "message/rfc822" indicates that the body contains an encapsulated message, with the syntax of an RFC 822 message. A valid Body could be the String: It has one Header followed by a newline that indicates that the Body Starts with the Text "Body messeage" So json is wrong here. An String example would solve this |
See OAS 2 specs regarding parameter object. You are free to use "message/rfc822" or anything else that's not in the specs, but you are on your own. |
I have tried your Message struct, it gives an json record in the "edit Value" field instead of an email. So its not possible to enter an normal string as body example? |
I got what i want by editing the docs/docs.go file:
It would be nice if it would be possible to generate this (also without quoting the \r\n chars). An example of a string in case of a body should be in the schema section |
@ubogdan what do you think about the PR ? Other idea is to include the Schema Example as default when body and example is used |
By the issue, I see a great job on schemaExample tag. Meanwhile, will you consider also have this tag available also for I have no idea on how to set example value for it. |
@mschneider82 The pr looks good so far, You only need to write the unit tests to cover the new code. See the codecov comments here https://github.com/swaggo/swag/pull/1148/files. |
@ubogdan i have covered the new code, please re-run codecov |
Hi @ubogdan i still have the problem that \r\n gets escaped. Do you have an idea how to solve it? My idea would be if the |
gets to:
What i need is:
|
It looks like you got defeated by your own unit tests. 🥲 |
@ubogdan the PR works with my Example! |
Hi,
I tried the new example feature for string:
// @Param email body string true "message/rfc822" example(Subject: Testmail\r\n\r\nBody Message\r\n)
Going to the swagger page it still shows "string" as the default Example Value. Howto change this to the example value? I would like to add a basic test mail as the text (which has a subject header and a message body)
The text was updated successfully, but these errors were encountered: