Skip to content

Commit

Permalink
Upgraded openapi-reader to support YAML (#10)
Browse files Browse the repository at this point in the history
Support for OpenAPI schema in YAML format
  • Loading branch information
francescozanoni authored and hkarlstrom committed Jan 24, 2019
1 parent 91d4e56 commit 45fc280
Show file tree
Hide file tree
Showing 4 changed files with 186 additions and 75 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
composer.phar
.DS_Store
/vendor/
.idea/

# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

PSR-7 and PSR-15 OpenAPI Validation Middleware

The middleware parses an OpenAPI definition document (openapi.json) and validates:
The middleware parses an OpenAPI definition document (openapi.json or openapi.yaml) and validates:
* Request parameters (path, query)
* Request body
* Response body
Expand All @@ -19,7 +19,7 @@ It's recommended that you use [Composer](https://getcomposer.org/download) to in
composer require hkarlstrom/openapi-validation-middleware
```

Use [Swagger/OpenAPI CLI](https://www.npmjs.com/package/swagger-cli) to validate openapi.json file, as the middleware assumes it to be valid.
Use [Swagger/OpenAPI CLI](https://www.npmjs.com/package/swagger-cli) to validate openapi.json/openapi.yaml file, as the middleware assumes it to be valid.


## Usage
Expand Down Expand Up @@ -52,9 +52,9 @@ $app->add(new HKarlstrom\Middleware\OpenApiValidation('/path/to/openapi.json'),[
| additionalParameters | bool | false | Allow additional parameters in query |
| beforeHandler | callable | null | Instructions [below](README.md#beforehandler) |
| errorHandler | callable | null | Instructions [below](README.md#errorhandler) |
| exampleResponse | bool | false | Return example response from openapi.json if route implementation is empty |
| exampleResponse | bool | false | Return example response from openapi.json/openapi.yaml if route implementation is empty |
| missingFormatException | bool | true | Throw an exception if a format validator is missing |
| pathNotFoundException | bool | true | Throw an exception if the path is not found in openapi.json |
| pathNotFoundException | bool | true | Throw an exception if the path is not found in openapi.json/openapi.yaml |
| setDefaultParameters | bool | false | Set the default parameter values for missing parameters and alter the request object |
| stripResponse | bool | false | Strip additional attributes from response to prevent response validation error |
| stripResponseHeaders | bool | false | Strip additional headers from response to prevent response validation error |
Expand Down Expand Up @@ -108,7 +108,7 @@ $app->add($mw);

#### Respect Validation

You can use [all the validators](http://respect.github.io/Validation/docs/validators.html) just by setting the `format` property in your openapi.json file.
You can use [all the validators](http://respect.github.io/Validation/docs/validators.html) just by setting the `format` property in your openapi.json/openapi.yaml file.
```json
"schema":{
"type" : "string",
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
],
"require": {
"php": "^7.1",
"ext-json": "*",
"ckr/arraymerger": "^2.0",
"hkarlstrom/openapi-reader": "^0.2.1",
"hkarlstrom/openapi-reader": "^0.3",
"opis/json-schema": "^1.0",
"psr/http-message": "^1.0",
"psr/http-server-middleware": "^1.0",
Expand Down
247 changes: 178 additions & 69 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 45fc280

Please sign in to comment.