Skip to content

Swagger spec fails validation #16748

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

Closed
nikhiljindal opened this issue Nov 3, 2015 · 6 comments
Closed

Swagger spec fails validation #16748

nikhiljindal opened this issue Nov 3, 2015 · 6 comments
Labels
area/swagger kind/bug Categorizes issue or PR as related to a bug. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery.

Comments

@nikhiljindal
Copy link
Contributor

Running swagger-tools validate api/swagger-spec/resourceListing.json api/swagger-spec/api.json api/swagger-spec/v1.json api/swagger-spec/version.json api/swagger-spec/apis.json api/swagger-spec/extensions.json api/swagger-spec/v1beta1.json gives:

  API Declaration (/api/v1) Errors:

    #/apis/1/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/3/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/4/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/6/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/7/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/8/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/9/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/10/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/12/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/13/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/14/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/15/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/16/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/18/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/19/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/20/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/21/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/22/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/24/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/27/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/28/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/30/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/31/operations/0/parameters/1/name: API path parameter could not be resolved: path
    #/apis/31/path: API requires path parameter but it is not defined: path:*
    #/apis/31/operations/1/parameters/1/name: API path parameter could not be resolved: path
    #/apis/31/path: API requires path parameter but it is not defined: path:*
    #/apis/31/operations/2/parameters/1/name: API path parameter could not be resolved: path
    #/apis/31/path: API requires path parameter but it is not defined: path:*
    #/apis/31/operations/3/parameters/1/name: API path parameter could not be resolved: path
    #/apis/31/path: API requires path parameter but it is not defined: path:*
    #/apis/31/operations/4/parameters/1/name: API path parameter could not be resolved: path
    #/apis/31/path: API requires path parameter but it is not defined: path:*
    #/apis/31/operations/5/parameters/1/name: API path parameter could not be resolved: path
    #/apis/31/path: API requires path parameter but it is not defined: path:*
    #/apis/34/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/35/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/37/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/38/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/39/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/41/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/42/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/44/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/46/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/47/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/49/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/50/operations/0/parameters/2/name: API path parameter could not be resolved: path
    #/apis/50/path: API requires path parameter but it is not defined: path:*
    #/apis/50/operations/1/parameters/2/name: API path parameter could not be resolved: path
    #/apis/50/path: API requires path parameter but it is not defined: path:*
    #/apis/50/operations/2/parameters/2/name: API path parameter could not be resolved: path
    #/apis/50/path: API requires path parameter but it is not defined: path:*
    #/apis/50/operations/3/parameters/2/name: API path parameter could not be resolved: path
    #/apis/50/path: API requires path parameter but it is not defined: path:*
    #/apis/50/operations/4/parameters/2/name: API path parameter could not be resolved: path
    #/apis/50/path: API requires path parameter but it is not defined: path:*
    #/apis/50/operations/5/parameters/2/name: API path parameter could not be resolved: path
    #/apis/50/path: API requires path parameter but it is not defined: path:*
    #/apis/52/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/53/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/57/operations/0/parameters/4/type: Model could not be resolved: *int64
    #/apis/57/operations/0/parameters/5/type: Model could not be resolved: *unversioned.Time
    #/apis/57/operations/0/parameters/7/type: Model could not be resolved: *int64
    #/apis/57/operations/0/parameters/8/type: Model could not be resolved: *int64
    #/apis/60/operations/0/parameters/3/name: Parameter already defined: path
    #/apis/60/operations/0/parameters/3/name: API path parameter could not be resolved: path
    #/apis/60/path: API requires path parameter but it is not defined: path:*
    #/apis/60/operations/1/parameters/3/name: Parameter already defined: path
    #/apis/60/operations/1/parameters/3/name: API path parameter could not be resolved: path
    #/apis/60/path: API requires path parameter but it is not defined: path:*
    #/apis/60/operations/2/parameters/3/name: Parameter already defined: path
    #/apis/60/operations/2/parameters/3/name: API path parameter could not be resolved: path
    #/apis/60/path: API requires path parameter but it is not defined: path:*
    #/apis/60/operations/3/parameters/3/name: Parameter already defined: path
    #/apis/60/operations/3/parameters/3/name: API path parameter could not be resolved: path
    #/apis/60/path: API requires path parameter but it is not defined: path:*
    #/apis/60/operations/4/parameters/3/name: Parameter already defined: path
    #/apis/60/operations/4/parameters/3/name: API path parameter could not be resolved: path
    #/apis/60/path: API requires path parameter but it is not defined: path:*
    #/apis/60/operations/5/parameters/3/name: Parameter already defined: path
    #/apis/60/operations/5/parameters/3/name: API path parameter could not be resolved: path
    #/apis/60/path: API requires path parameter but it is not defined: path:*
    #/apis/62/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/63/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/65/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/66/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/67/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/68/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/69/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/71/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/72/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/73/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/75/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/76/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/78/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/79/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/80/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/82/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/83/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/85/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/86/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/87/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/88/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/89/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/91/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/92/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/93/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/94/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/95/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/97/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/98/operations/0/parameters/2/name: API path parameter could not be resolved: path
    #/apis/98/path: API requires path parameter but it is not defined: path:*
    #/apis/98/operations/1/parameters/2/name: API path parameter could not be resolved: path
    #/apis/98/path: API requires path parameter but it is not defined: path:*
    #/apis/98/operations/2/parameters/2/name: API path parameter could not be resolved: path
    #/apis/98/path: API requires path parameter but it is not defined: path:*
    #/apis/98/operations/3/parameters/2/name: API path parameter could not be resolved: path
    #/apis/98/path: API requires path parameter but it is not defined: path:*
    #/apis/98/operations/4/parameters/2/name: API path parameter could not be resolved: path
    #/apis/98/path: API requires path parameter but it is not defined: path:*
    #/apis/98/operations/5/parameters/2/name: API path parameter could not be resolved: path
    #/apis/98/path: API requires path parameter but it is not defined: path:*
    #/apis/100/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/101/operations/0/parameters/5/type: Model could not be resolved: *int64

  API Declaration (/apis/extensions/v1beta1) Errors:

    #/apis/0/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/1/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/3/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/4/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/5/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/7/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/8/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/10/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/11/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/12/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/14/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/15/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/17/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/18/operations/0/parameters/5/type: Model could not be resolved: *int64
    #/apis/19/operations/0/parameters/5/type: Model could not be resolved: *int64

138 errors and 0 warnings

cc @caesarxuchao @bgrant0607 @lavalamp

@nikhiljindal nikhiljindal added kind/bug Categorizes issue or PR as related to a bug. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. area/swagger labels Nov 3, 2015
@lavalamp lavalamp added the priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. label Nov 3, 2015
@lavalamp
Copy link
Member

lavalamp commented Nov 3, 2015

Can we run this automatically?

@nikhiljindal
Copy link
Contributor Author

@lavalamp Yes plan is to add a test for this #5356

There are 3 main failures:

  • Convert *int64 to integer
  • Convert *unversioned.Time to string
  • Handle {path:*}

#16774 fixes the first 2.

Third one requires more thought.
Paths of the form {/path:*} are not supported by swagger spec (as per discussion in OAI/OpenAPI-Specification#502)
We have been using them since a long time, by naming our path param path:*. But that resulted in broken generated clients (#13198)
#14049 fixed it by removing the asterix, but now swagger spec validation fails.

So if we keep the asterix in param name, then the generated clients will be broken.
If we remove the asterix, then swagger-spec validation fails.
I think swagger-spec validation passing is more important, but would like to know what others think.

cc @bgrant0607 @lavalamp @brendandburns

@nikhiljindal
Copy link
Contributor Author

First 2 were fixed by #16774
#17990 fixes the 3rd one.

But now there is a new one:

API Declaration (/api/v1) Errors:

    #/apis/60/operations/0/parameters/3/name: Parameter already defined: path
    #/apis/60/operations/1/parameters/3/name: Parameter already defined: path
    #/apis/60/operations/2/parameters/3/name: Parameter already defined: path
    #/apis/60/operations/3/parameters/3/name: Parameter already defined: path
    #/apis/60/operations/4/parameters/3/name: Parameter already defined: path
    #/apis/60/operations/5/parameters/3/name: Parameter already defined: path

6 errors and 0 warnings

This looks like a swagger-tools bug: apigee-127/swagger-tools#307

@whitlockjc
Copy link
Contributor

I'm looking into this.

@whitlockjc
Copy link
Contributor

whitlockjc commented Oct 18, 2016

First pass looks like this:

swagger-tools validate api/swagger-spec/resourceListing.json api/swagger-spec/api.json api/swagger-spec/apis.json api/swagger-spec/apps.json api/swagger-spec/apps_v1alpha1.json api/swagger-spec/authentication.k8s.io.json api/swagger-spec/authentication.k8s.io_v1.json api/swagger-spec/authentication.k8s.io_v1beta1.json api/swagger-spec/authorization.k8s.io.json api/swagger-spec/authorization.k8s.io_v1beta1.json api/swagger-spec/autoscaling.json api/swagger-spec/autoscaling_v1.json api/swagger-spec/batch.json api/swagger-spec/batch_v1.json api/swagger-spec/batch_v2alpha1.json api/swagger-spec/certificates.k8s.io.json api/swagger-spec/certificates.k8s.io_v1alpha1.json api/swagger-spec/extensions.json api/swagger-spec/extensions_v1beta1.json api/swagger-spec/logs.json api/swagger-spec/policy.json api/swagger-spec/policy_v1alpha1.json api/swagger-spec/rbac.authorization.k8s.io.json api/swagger-spec/rbac.authorization.k8s.io_v1alpha1.json api/swagger-spec/storage.authorization.k8s.io_v1beta1.json api/swagger-spec/storage.k8s.io.json api/swagger-spec/storage.k8s.io_v1beta1.json api/swagger-spec/v1.json api/swagger-spec/version.json


  API Declaration (/api) Errors:

    #: Additional properties not allowed: info

  API Declaration (/apis) Errors:

    #: Additional properties not allowed: info

  API Declaration (/apis/apps) Errors:

    #: Additional properties not allowed: info

  API Declaration (/apis/apps/v1alpha1) Errors:

    #: Additional properties not allowed: info

  API Declaration (/apis/authentication.k8s.io) Errors:

    #: Additional properties not allowed: info

  API Declaration (/apis/authentication.k8s.io/v1beta1) Errors:

    #: Additional properties not allowed: info

  API Declaration (/apis/authorization.k8s.io) Errors:

    #: Additional properties not allowed: info

  API Declaration (/apis/authorization.k8s.io/v1beta1) Errors:

    #: Additional properties not allowed: info

  API Declaration (/apis/autoscaling) Errors:

    #: Additional properties not allowed: info

  API Declaration (/apis/autoscaling/v1) Errors:

    #: Additional properties not allowed: info

  API Declaration (/apis/batch) Errors:

    #: Additional properties not allowed: info

  API Declaration (/apis/batch/v1) Errors:

    #: Additional properties not allowed: info

  API Declaration (/apis/batch/v2alpha1) Errors:

    #: Additional properties not allowed: info

  API Declaration (/apis/certificates.k8s.io) Errors:

    #: Additional properties not allowed: info

  API Declaration (/apis/certificates.k8s.io/v1alpha1) Errors:

    #: Additional properties not allowed: info

  API Declaration (/apis/extensions) Errors:

    #: Additional properties not allowed: info

  API Declaration (/apis/extensions/v1beta1) Errors:

    #: Additional properties not allowed: info

  API Declaration (/logs) Errors:

    #: Additional properties not allowed: info

  API Declaration (/apis/policy) Errors:

    #: Additional properties not allowed: info

  API Declaration (/apis/policy/v1alpha1) Errors:

    #: Additional properties not allowed: info

  API Declaration (/apis/rbac.authorization.k8s.io) Errors:

    #: Additional properties not allowed: info

  API Declaration (/apis/rbac.authorization.k8s.io/v1alpha1) Errors:

    #: Additional properties not allowed: info

  API Declaration (/apis/storage.k8s.io) Errors:

    #: Additional properties not allowed: info

  API Declaration (/apis/storage.k8s.io/v1beta1) Errors:

    #: Additional properties not allowed: info

  API Declaration (/api/v1) Errors:

    #: Additional properties not allowed: info

  API Declaration (/version) Errors:

    #: Additional properties not allowed: info

26 errors and 0 warnings

It appears each API Declaration has an info property and that is not allowed. (See: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/1.2.md#52-api-declaration) I will start with that and once I'm there I'm sure I'll see the same things you are above.

As the author of swagger-tools, I can tell you that the error you're seeing above should be fixable for the CLI validation without issue. I personally don't agree with multiple parameters in the same request having the same name but that's a topic for another day.

@calebamiles calebamiles modified the milestone: v1.6 Mar 8, 2017
@grodrigues3 grodrigues3 removed this from the v1.6 milestone Mar 10, 2017
@mbohlool
Copy link
Contributor

The Swagger/OpenAPI spec is valid and tested here https://github.com/kubernetes/kubernetes/blob/master/pkg/master/master_openapi_test.go. The old swagger 1.2 is deprecated and will be removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/swagger kind/bug Categorizes issue or PR as related to a bug. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery.
Projects
None yet
Development

No branches or pull requests

6 participants