Skip to content
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

in: formData in swagger:route annotation translates to nothing (in field is omitted) in the yaml spec file #3100

Open
devyetii opened this issue Apr 14, 2024 · 1 comment

Comments

@devyetii
Copy link

Problem statement

in: formData in swagger:route annotation translates to nothing (in field is omitted) in the yaml spec file. It's specified in the Swagger 2.0 Specs that to specify a field is provided as application/x-www-form-urlencoded or multipart/form-data in a POST request, its in field value should be formData. Looking into the code, specifically here, looks like the valid values for the in field doesn't contain formData, but contains form which I believe has the same meaning.
My suggestion is to have this stated somewhere in the docs (my bad if it's already there, I tried to look for it but couldn't find it mentioned anywhere).

Thanks for this extremely helpful tool!

Steps to reproduce

  • Add swagger:route annotation with a param with in as formData
// swagger:route POST /v1/example/route operationName
// Very important operation
// consumes:
//   - application/x-www-form-urlencoded
// parameters:
// ......
// ......
// ......
//  +name: encryption_public_key
//     description: Public key of the referee client in case of private sharing. Used for proxy re-encryption.
//     in: formData
//     type: string
// .......
// .......
// .......
// responses:
// ......
// ......
  • Run swagger generate spec to generate the yaml file
swagger generate spec -o ./swagger.yaml -w ./my/module/path -m
  • Inspect the generated yaml file, you'll find the following for this field:
                - description: Public key of the referee client in case of private sharing. Used for proxy re-encryption.
                  name: encryption_public_key
                  type: string

As you can see, noin field at all.

Environment

swagger version: v0.30.6-0.20240131062529-abb53530bfcf
go version: go1.22.1 darwin/arm64
OS: MacOS 13.2.1 (22D68) over M1 Pro Chip

@devyetii
Copy link
Author

Additionally, in: form doesn't pass swagger 2.0 validation, since only formData is allowed. This causes any generation of presentable format (like md) to fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant