Skip to content

Validation for swagger.yaml#28038

Merged
vdemeester merged 3 commits intomoby:masterfrom
bfirsh:add-validate-swagger
Nov 8, 2016
Merged

Validation for swagger.yaml#28038
vdemeester merged 3 commits intomoby:masterfrom
bfirsh:add-validate-swagger

Conversation

@bfirsh
Copy link
Copy Markdown
Contributor

@bfirsh bfirsh commented Nov 3, 2016

- What I did

Add a script to validate swagger.yaml if it is changed. Also made some improvements to swagger.yaml. Part of #27919

- How I did it

There are heaps of tools to validate Swagger files, and each validate a subset of the various things that can be validated. This PR only adds go-swagger, which seems to cover the main possible problems.

Ideally, I'd also like to use swagger-tools, because that catches some stuff that go-swagger doesn't, but with the current build system that'd mean installing Node.js in the already enormous build image. I could have run a separate Docker image, but that's difficult to to do in Docker-in-Docker because the volumes end up in different places.

- A picture of a cute animal (not mandatory but encouraged)

b2c58d9fb83baf3c6f005b62d7605e8f

/cc @dnephin

@vdemeester
Copy link
Copy Markdown
Member

/cc @dnephin

@vieux
Copy link
Copy Markdown
Contributor

vieux commented Nov 3, 2016

Should we edit the Makefile as well ? Maybe always validate after a gen ?

@vdemeester
Copy link
Copy Markdown
Member

Linking #27964 to it too 👼

Copy link
Copy Markdown
Member

@dnephin dnephin left a comment

Choose a reason for hiding this comment

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

This will conflict with #27964 so whichever is last to merge will have to resolve the conflicts.

Comment thread Dockerfile Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should we pin a version here as well? yamllint==x.y.z

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed, thanks!

Comment thread Dockerfile Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've been trying to avoid adding more to this Dockerfile and splitting things up into different images (#27359).

Right now the generation uses a separate image.

But I guess until #27359 merges that is going to be difficult, so this is ok for now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I initially tried doing it in separate images, but it was a bit messy and going against the current pattern. Once #27359 merges I'll fix it, and it'll let us add the swagger-tools validator too. :)

@bfirsh bfirsh force-pushed the add-validate-swagger branch from 9beb7d5 to 20d2aa7 Compare November 3, 2016 18:39
@bfirsh
Copy link
Copy Markdown
Contributor Author

bfirsh commented Nov 3, 2016

Ahah, I didn't notice #27964! I'm happy to wait and fix this up when it merges.

@bfirsh bfirsh force-pushed the add-validate-swagger branch from 20d2aa7 to 1576e1c Compare November 4, 2016 01:14
@bfirsh
Copy link
Copy Markdown
Contributor Author

bfirsh commented Nov 4, 2016

Rebased on top of #27964. ✨

Copy link
Copy Markdown
Member

@dnephin dnephin left a comment

Choose a reason for hiding this comment

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

LGTM!

@dnephin
Copy link
Copy Markdown
Member

dnephin commented Nov 4, 2016

Oh, one thing I missed. Can you add this to hack/validate/all and hack/validate/default ?

@dnephin
Copy link
Copy Markdown
Member

dnephin commented Nov 4, 2016

Should we edit the Makefile as well ? Maybe always validate after a gen ?

As long as we add it to all and default we don't need to edit the makefile.

I don't think we need to run it after a gen. Generate creates the types no the spec. We could run it before the generate, but I don't think that's really necessary either. Running it as part of CI should be plenty.

@bfirsh
Copy link
Copy Markdown
Contributor Author

bfirsh commented Nov 4, 2016

@dnephin I added it to hack/validate/default, which is run by hack/validate/all. Is anything more needed than that?

@dnephin
Copy link
Copy Markdown
Member

dnephin commented Nov 4, 2016

Oh, right!

LGTM

@vieux
Copy link
Copy Markdown
Contributor

vieux commented Nov 5, 2016

@dnephin shouldn't we edit the Makefile as well ?

@thaJeztah
Copy link
Copy Markdown
Member

@bfirsh can you squash your commits?

@dnephin
Copy link
Copy Markdown
Member

dnephin commented Nov 5, 2016

@vieux edit it how?

#28038 (comment)

Signed-off-by: Ben Firshman <[email protected]>
- Some objects were missing `type: "object"`
- Some examples had invalid null values (go-swagger validation
  doesn't support x-nullable, so they have just been removed)
- ImageSummary example was out of date
- Removed timeNano because YAML interprets it as a float, not
  a long (sigh)
- Tidy up archive errors

Signed-off-by: Ben Firshman <[email protected]>
- yamllint to ensure it is a valid YAML file
- go-swagger validate to ensure it is a valid swagger file

Signed-off-by: Ben Firshman <[email protected]>
@bfirsh bfirsh force-pushed the add-validate-swagger branch from 1576e1c to 5c4abd1 Compare November 7, 2016 19:03
@bfirsh
Copy link
Copy Markdown
Contributor Author

bfirsh commented Nov 7, 2016

@thaJeztah Squashed the two commits cleaning up/fixing things in swagger.yaml. Everything else make sense as separate commits, I think (they could be separate PRs).

@vieux
Copy link
Copy Markdown
Contributor

vieux commented Nov 7, 2016

@dnephin sorry I misread you comment, LGTM

@vdemeester vdemeester merged commit 9075aa4 into moby:master Nov 8, 2016
@bfirsh bfirsh deleted the add-validate-swagger branch November 14, 2016 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants