Skip to content
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

Expose a valid OpenApi specification #613

Merged
merged 1 commit into from
May 31, 2022

Conversation

nelsonkopliku
Copy link
Member

I noticed our openapi spec is not valid (shame on me 😄 )

image

here are the reasons https://validator.swagger.io/validator/debug?url=http%3A%2F%2Fdemo.trento-project.io%2Fapi%2Fopenapi

{
  "messages": [
    "attribute paths.'/api/clusters/{cluster_id}/checks'(post).parameters.[selected_checks].in is not of type `string`",
    "attribute paths.'/api/runner/callback'(post).parameters.[callback_event].in is not of type `string`",
    "attribute components.schemas.Schema name IP address doesn't adhere to regular expression ^[a-zA-Z0-9\\.\\-_]+$"
  ],
  "schemaValidationMessages": [
    {
      "level": "error",
      "domain": "validation",
      "keyword": "oneOf",
      "message": "instance failed to match exactly one schema (matched 0 out of 2)",
      "schema": {
        "loadingURI": "#",
        "pointer": "/definitions/Operation/properties/parameters/items"
      },
      "instance": {
        "pointer": "/paths/~1api~1clusters~1{cluster_id}~1checks/post/parameters/1"
      }
    }
  ]
}

with these changes we it's green again
image

image

image

@nelsonkopliku nelsonkopliku self-assigned this May 30, 2022
@nelsonkopliku nelsonkopliku added bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request labels May 30, 2022
Copy link
Contributor

@arbulu89 arbulu89 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice thing!
How did you generate the swagger validation output? Or is it just this online service?
Maybe we could integrate something like this in our CI

@nelsonkopliku
Copy link
Member Author

nelsonkopliku commented May 30, 2022

Nice thing! How did you generate the swagger validation output? Or is it just this online service? Maybe we could integrate something like this in our CI

Here https://validator.swagger.io/ then you provide the url of a reachable openapi spec.
Because it doesn't work with localhost I cheated and used ngrok and provided this URL https://5faa-79-18-240-47.eu.ngrok.io/api/doc which is basically my machine ™️

We can put to production our machines eheh 😂

Anyway, I believe there should be some validator to be used programmatically, even in CI, but I didn't go there yet.

EDIT:
You can get this url https://validator.swagger.io/validator/debug?url=http%3A%2F%2Fdemo.trento-project.io%2Fapi%2Fopenapi by clicking on the invalid tag on our openapi doc on demo http://demo.trento-project.io/api/doc

@nelsonkopliku nelsonkopliku merged commit 7278919 into main May 31, 2022
@nelsonkopliku nelsonkopliku deleted the expose_a_valid_openapi_spec branch May 31, 2022 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

2 participants