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

Validation classes, OAS 3 Router Factory and OAS 3 Validation handler #666

Merged
merged 69 commits into from
Oct 7, 2017

Conversation

slinkydeveloper
Copy link
Member

This PR provides the three main features of the project:

  • Classes for validation of http requests (inside vertx-web package)
  • Classes common to design driven router factories (inside vertx-web-api-contract-common), for future implementations
  • Classes for OAS 3 router factory and OAS 3 Validation (inside vertx-web-api-contract-openapi)

Also I provide tests for validation and oas3 inside respective packages

slinkydeveloper and others added 30 commits May 9, 2017 08:32
Removed asynchronous implementation of validator
Implemented form validation, query validation, path validation, headers validation, custom validators, file name validation inside BaseValidationHandler
Refactored some class names
Writed functions and javadocs of HTTPRequestValidationHandler interface
Writed Javadoc of ValidationHandler
Writed Javadoc of CustomValidator
Switched from String regexp to Pattern regexp object to allow pattern check
Writed function and Javadoc for HTTPOperationRequestValidationHandler interface
Moved ParameterType and ParameterLocation
Added to pom.xml swagger-parser library
Writed tests for parameter type validation methods
Started writing HTTPRequestValidationTest
Improved queryParams method test inside RouterTest
Refactored ValidationRule: Moved and renamed in ParameterValidationRule and now check array params internally
Created NumericTypeValidator, StringEnumTypeValidator, StringTypeValidator (from PatternTypeValidator)
Refactored ValidationException, BaseValidationHandler, HTTPRequestValidationHandler to support new validation mechanism
Now an array param is managed by ParameterValidationRule only if collection format is multi (for example /hello?param=value&param=value2 ), every other types of collection formats are managed by ArrayTypeValidator
Added some tests to Swagger2RequestValidationHandlerTest
Added long type suppport in Swagger 2 operation parsing
Added 400 response when content type not found
…olean function and it can throw a ValidationException (but only with a message and a ErrorType)

Removed Swagger2RequestValidationHandler
Refactored validation behavior for arrays and objects to support OpenAPI 3
Removed Swagger2RequestValidationHandler
Refactored validation behavior for arrays and objects to support OpenAPI 3
Renamed OpenAPI3RequestValidationHandler
Added some tests to OpenAPI3ValidationTest
Merged RouteImpl queryParams() fix
Refactored validation mechanism to allow request parameters encapsulation
Added some unit tests
Added JsonObject in RequestParameter
Added cookie validation support
Wrote some tests for OpenAPI3
Added more unit tests to for OpenAPI3
Fixed code generation errors
Added OpenAPI3RouterFactoryTest and tested OpenAPI3RouterFactory
Added unit test for multipart support
Refactored code and APIs to Vertx project guidelines
Added isEmpty() as alias of isNull() in RequestParameter
added basic poms for api contracts
slinkydeveloper and others added 19 commits August 17, 2017 16:43
# Conflicts:
#	vertx-web/src/main/asciidoc/enums.adoc
#	vertx-web/src/main/java/examples/WebExamples.java
encoding shoulb be on the same level as schema in a MediaType
https://swagger.io/specification/#mediaTypeObject
in /pets/{petId}, if petId is defined as a string, then 3 is a valid
value (it will be seen as "3").
Just changing string to number and adapating 3 tests.
The swagger-parser doesn't resolve by default $ref schemas. There is an
option in the parser to activate it, but it has side effects (no more
allOf for instance since all items of an allOf array are merged into one
single schema)

So when a parameter schema has a $ref, this schema is overridden by the
$ref schema, found in the spec object
Since a parameter can be 'not required', if it is not in the request, it
does not mean it's an error
Since the spec validation is always done with the swagger-parser.
It allows using the modified version of the swagger-parser in my repo :
https://github.com/phiz71/swagger-parser
Waiting for my PRs to be merged.
since package-info has been modified
Added test for circular references
Removed jitpack from maven repositories
@slinkydeveloper
Copy link
Member Author

Thank you to @phiz71 work, now we use official swagger-parser library (v2) published to maven central. All test pass and now this code is ready to be merged.

@phiz71
Copy link
Contributor

phiz71 commented Sep 15, 2017

Maybe we should wait for a 2.0.0-rc1 instead of a SNAPSHOT ?

@@ -46,6 +46,18 @@
<optional>true</optional>
</dependency>

<!-- Validation dependencies -->
Copy link
Member

Choose a reason for hiding this comment

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

these dependencies should go with the oas module pom not the root pom

Copy link
Member Author

Choose a reason for hiding this comment

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

They are only about json validation, that is included inside vertx-web module

Copy link
Member

Choose a reason for hiding this comment

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

Yes I understand but they should be declared on the module Pom not the top level because otherwise users not using oas will get them included in their projects without needing it

@phiz71
Copy link
Contributor

phiz71 commented Oct 6, 2017

Rc1 of Swagger-parser has been released. It contains all the PRs I made and that are necessary for vertx-web-oas.
https://github.com/swagger-api/swagger-parser/releases/tag/v2.0.0-rc1

@vietj
Copy link
Contributor

vietj commented Oct 7, 2017

can we finish the review of this PR so it can be merged for 3.5 ?

@pmlopes pmlopes merged commit 594cdcf into vert-x3:master Oct 7, 2017
@pmlopes pmlopes removed the to review label Oct 7, 2017
@pmlopes
Copy link
Member

pmlopes commented Oct 7, 2017

@slinkydeveloper @phiz71 thank you. I've moved some code around to keep this feature isolated on its own module and we should have on 3.5 as tech preview.

@phiz71
Copy link
Contributor

phiz71 commented Oct 7, 2017

I feel proud, even if did 1% of the whole work 😄
It's my very first contribution to Vertx. 🎉

@vietj
Copy link
Contributor

vietj commented Oct 8, 2017

we consider your OSS project as a contribute to Vert.x in general :-)

@slinkydeveloper
Copy link
Member Author

GSoC project completed! Now I'm ready for the next one 😄!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants