Skip to content

Error creating an API using swagger v2 with schema ref #494

@renuka-fernando

Description

@renuka-fernando

Description:
Error creating an API using swagger v2 having schema ref definitions, without having components/schemas instead having definitions

{
    "/user/createWithArray": {
        "post": {
            "tags": [
                "user"
            ],
            "summary": "Creates list of users with given input array",
            "description": "",
            "operationId": "createUsersWithArrayInput",
            "consumes": [
                "application/json"
            ],
            "produces": [
                "application/json",
                "application/xml"
            ],
            "parameters": [
                {
                    "in": "body",
                    "name": "body",
                    "description": "List of user object",
                    "required": true,
                    "schema": {
                        "type": "array",
                        "items": {
                            "$ref": "#/definitions/User"
                        }
                    }
                }
            ],
            "responses": {
                "default": {
                    "description": "successful operation"
                }
            }
        }
    }
}

Error log

{"level":"error","ts":1605695352.117046,"logger":"controller-runtime.controller","msg":"Reconciler error","controller":"api-controller","request":"wso2-system/petstore222","error":"expected prefix '#/components/schemas/' in URI '#/definitions/User'","stacktrace":"github.com/go-logr/zapr.(*zapLogger).Error\n\tapi-operator/vendor/github.com/go-logr/zapr/zapr.go:128\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler\n\tapi-operator/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:258\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\tapi-operator/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:232\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).worker\n\tapi-operator/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:211\nk8s.io/apimachinery/pkg/util/wait.BackoffUntil.func1\n\tapi-operator/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:155\nk8s.io/apimachinery/pkg/util/wait.BackoffUntil\n\tapi-operator/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:156\nk8s.io/apimachinery/pkg/util/wait.JitterUntil\n\tapi-operator/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:133\nk8s.io/apimachinery/pkg/util/wait.Until\n\tapi-operator/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:90"}

Suggested Labels:
bug

Affected Product Version:
API Operator 1.2.2

Steps to reproduce:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions