3

I am not sure how to specify annotation for an input string parameter for a rest call. Where input parameter can take one of three possible string values.

If I have to assume there will be a drop down menu with these three value (containers/bundles/web) and the user will chose one of them. Previously I am referring to this documentation to create annotation for an in parameters.

I am trying to annotate go code, so that I can generate swagger.yaml automatically (swagger generate spec -o ./swagger.yaml --scan-models). Unfortunately, I couldn't find an annotated example that expects enums or the input parameters is limited to certain values. Looks for some code examples.

Helen
  • 87,344
  • 17
  • 243
  • 314
BhanuKiran
  • 2,631
  • 3
  • 20
  • 36
  • Are you trying to annotate your Go code to produce a Swagger specification? Or are you trying to generate a server from a Swagger specification? – Micah Parks Jan 21 '22 at 21:55
  • @MicahParks I am trying to annotate go code, so that I can generate ```swagger.yaml ``` automatically (```swagger generate spec -o ./swagger.yaml --scan-models```) – BhanuKiran Jan 22 '22 at 08:33

1 Answers1

1

some thing like this with enum annotation should work.

// swagger:parameters artifactInfo
type ArtifactTypeParam struct {
    // The type of artifact
    // in: path
    // enum: container,bundle,executbale
    // required: true
    ArtifactType string `json:"artifactType"`
}
BhanuKiran
  • 2,631
  • 3
  • 20
  • 36