createParameter returns swagger spec.Parameter for given paramType, description, paramName, schemaType, required.
(paramType, description, paramName, objectType, schemaType string, format string, required bool, enums []interface{}, collectionFormat string)
| 1187 | |
| 1188 | // createParameter returns swagger spec.Parameter for given paramType, description, paramName, schemaType, required. |
| 1189 | func createParameter(paramType, description, paramName, objectType, schemaType string, format string, required bool, enums []interface{}, collectionFormat string) spec.Parameter { |
| 1190 | // //five possible parameter types. query, path, body, header, form |
| 1191 | result := spec.Parameter{ |
| 1192 | ParamProps: spec.ParamProps{ |
| 1193 | Name: paramName, |
| 1194 | Description: description, |
| 1195 | Required: required, |
| 1196 | In: paramType, |
| 1197 | }, |
| 1198 | } |
| 1199 | |
| 1200 | if paramType == "body" { |
| 1201 | return result |
| 1202 | } |
| 1203 | |
| 1204 | switch objectType { |
| 1205 | case ARRAY: |
| 1206 | result.Type = objectType |
| 1207 | result.CollectionFormat = collectionFormat |
| 1208 | result.Items = &spec.Items{ |
| 1209 | CommonValidations: spec.CommonValidations{ |
| 1210 | Enum: enums, |
| 1211 | }, |
| 1212 | SimpleSchema: spec.SimpleSchema{ |
| 1213 | Type: schemaType, |
| 1214 | Format: format, |
| 1215 | }, |
| 1216 | } |
| 1217 | case PRIMITIVE, OBJECT: |
| 1218 | result.Type = schemaType |
| 1219 | result.Enum = enums |
| 1220 | result.Format = format |
| 1221 | } |
| 1222 | return result |
| 1223 | } |
| 1224 | |
| 1225 | func getCodeExampleForSummary(summaryName string, dirPath string) ([]byte, error) { |
| 1226 | dirEntries, err := os.ReadDir(dirPath) |
no outgoing calls
no test coverage detected
searching dependent graphs…