(name string, api *runtimev1.API)
| 244 | } |
| 245 | |
| 246 | func (s *Server) generatePathItemSpec(name string, api *runtimev1.API) (*openapi3.PathItem, map[string]*openapi3.SchemaRef, error) { |
| 247 | summary := "" |
| 248 | if api.Spec.OpenapiSummary != "" { |
| 249 | summary = api.Spec.OpenapiSummary |
| 250 | } |
| 251 | if summary == "" { |
| 252 | summary = fmt.Sprintf("Query %s resolver", name) |
| 253 | } |
| 254 | |
| 255 | var parameters openapi3.Parameters |
| 256 | if api.Spec.OpenapiParametersJson != "" { |
| 257 | var err error |
| 258 | parameters, err = openapiutil.ParseJSONParameters(api.Spec.OpenapiParametersJson) |
| 259 | if err != nil { |
| 260 | return nil, nil, err |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | components := make(map[string]*openapi3.SchemaRef) |
| 265 | |
| 266 | var requestBody *openapi3.RequestBodyRef |
| 267 | if api.Spec.OpenapiRequestSchemaJson != "" { |
| 268 | s, cs, err := openapiutil.ParseJSONSchema(api.Spec.OpenapiDefsPrefix, api.Spec.OpenapiRequestSchemaJson) |
| 269 | if err != nil { |
| 270 | return nil, nil, err |
| 271 | } |
| 272 | |
| 273 | for k, v := range cs { |
| 274 | components[k] = v |
| 275 | } |
| 276 | |
| 277 | requestBody = &openapi3.RequestBodyRef{ |
| 278 | Value: &openapi3.RequestBody{ |
| 279 | Content: openapi3.NewContentWithJSONSchema(s), |
| 280 | }, |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | var responseSchema *openapi3.Schema |
| 285 | if api.Spec.OpenapiResponseSchemaJson != "" { |
| 286 | s, cs, err := openapiutil.ParseJSONSchema(api.Spec.OpenapiDefsPrefix, api.Spec.OpenapiResponseSchemaJson) |
| 287 | if err != nil { |
| 288 | return nil, nil, err |
| 289 | } |
| 290 | |
| 291 | for k, v := range cs { |
| 292 | components[k] = v |
| 293 | } |
| 294 | |
| 295 | responseSchema = s |
| 296 | } else { |
| 297 | responseSchema = &openapi3.Schema{ |
| 298 | Type: &openapi3.Types{"object"}, |
| 299 | } |
| 300 | } |
| 301 | |
| 302 | op := &openapi3.Operation{ |
| 303 | Summary: summary, |
no test coverage detected