12 Commits

Author SHA1 Message Date
Yuriy Belenko
39aeb4a8ae
[Slim4] Add Data Mocker middleware (#4978)
* [Slim4] Store response schemas

* [Slim4] Add Data Mocker middleware

* [Slim4] Enhance Slim router

* [Slim4] Enhance config

* [Slim4] Fix data format key in object mocking

* [Slim4] Add tests for Data Mocker middleware

* [Slim4] Add Mock feature documentation

* [Slim4] Refresh samples
2020-03-03 23:53:57 +08:00
Yuriy Belenko
0366e946ba [Slim4] Add string formats support to Data Mocker (#4975)
* [Slim4] Support byte data format

* [Slim4] Support date and date-time data formats

* [Slim4] Support password data format

* [Slim4] Support uuid data format

* [Slim4] Fix test of password format mocking

'00000' is numeric type, because PHPUnit doesn't make strict type
comparison.

* [Slim4] Fix data format key in object mocking

* [Slim4] Support binary data format

* [Slim4] Support email data format

* [Slim4] Base64 encode binary format output

Raw bytes string breaks PHP stdout output, so I've decided to use base64
encoding format for binary format too.

* [Slim4] Refresh samples
2020-01-23 16:18:18 +08:00
Yuriy Belenko
420039c9eb [Slim4] Add integer formats support to Data Mocker (#4965)
* [Slim4] Support int32 and int64 data formats

* [Slim4] Fix data format key in object mocking

* [Slim4] Refresh samples
2020-01-18 16:08:13 +08:00
William Cheng
20c7400d56 update samples 2020-01-10 21:51:59 +08:00
Yuriy Belenko
6dcdf5c311 [Slim4] Add ref support to Data Mocker (#4932)
* [Slim4] Add new method to Mocker interface

* [Slim4] Add implementation and tests for new method

* [Slim4] Add test fixture to encrease code coverage

* [Slim4] Add ref support to mockArray method

* [Slim4] Add mockFromRef method

* [Slim4] Add ref support to mockObject method

* [Slim4] Add ModelInterface

* [Slim4] Refresh samples

* [Slim4] Add ref support to mockFromSchema method

* [Slim4] Run all test suites by default test command

As it turnes out to generate coverage report for a whole project I need
to run all test suites at once.

* [Slim4] Fix enum option of string mocking
2020-01-10 16:27:43 +08:00
William Cheng
54cfab84b6 run ensure-up-to-date 2019-12-28 01:12:26 +08:00
Yuriy Belenko
ca4f718748 [Slim4] Add ModelUtils and StringUtils (#4855)
* [Slim4] Add StringUtils and ModelUtils classes

* [Slim4] Refresh samples
2019-12-22 15:04:30 +08:00
Yuriy Belenko
04ac754d3e [Slim4] Add object support to Data Mocker (#4853)
* [Slim4] Add new method to Mocker interface

* [Slim4] Add tests and implement mockObject method

* [Slim4] Accept items as object in mockArray method

* [Slim4] Add test for array of objects

* [Slim4] Refresh samples

* [Slim4] Remove abandoned debug comment

* [Slim4] Improve tests code coverage
2019-12-22 15:03:22 +08:00
Yuriy Belenko
0ae1ea68fb [Slim4] Add array support to Data Mocker (#4801)
* [Slim4] Add new method to Mocker interface

* [Slim4] Add tests and implement mockArray method

* [Slim4] Refresh samples

* [Slim4] Extract OAS properties in separated method
2019-12-18 09:59:35 +08:00
Yuriy Belenko
7bd378c026 [Slim4] Data mocker for scalar types (#4751)
* [Slim4] Add OpenApiDataMocker interface template

* [Slim4] Implement scalar types in data mocker

* [Slim4] Cleanup, remove unused variables

I've rejected the idea to keep Composer dependencies in Java/codegen
variables at some point of time. It seems that after Git rebase I forgot
to delete them.

* [Slim4] Refresh samples

* [Slim4] Add pattern option to mockString method

[ref] https://tools.ietf.org/html/draft-wright-json-schema-validation-00#section-5.8

* [Slim4] Add enum option to mockString method

[ref] https://tools.ietf.org/html/draft-wright-json-schema-validation-00#section-5.20

* [Slim4] Refactor mockInteger and mockNumber tests

* [Slim4] Refactor mockString tests

* [Slim4] Use null coalescing operator

* [Slim4] Implement enum option in mockString method

* [Slim4] Add tests for enum option of mockString
2019-12-16 17:32:07 +08:00
Yuriy Belenko
41bb41c87c [Slim4] Update templates to comply PSR-12 coding style (#4728)
* [Slim4] Bump PHP_CodeSniffer version to 3.5.*

* [Slim4] Update samples

* [Slim4] Update template to meet PSR-12
2019-12-09 11:20:21 +08:00
Yuriy Belenko
8e78b14e28 New PHP Slim4 Server Generator (#3658)
* [Slim4] Copy Slim3 generator as starting point

* [Slim4] Add psr7Implementation generator option

Slim supports PSR-7 interfaces for its Request and Response objects.
Slim provides its own PSR-7 implementation so that it works out of the
box.
However, you are free to replace Slim’s default PSR-7 objects with
a third-party implementation.
[Ref] https://www.slimframework.com/docs/v4/concepts/value-objects.html

* [Slim4] Handle psr7Implementation generator option

It somehow ended up with composerPackages and composerDevPackages
codegen variables and two additional functions. Hope, it's not too much.

* [Slim4] Extend from Slim3 generator

* [Slim4] Bump PHP Slim Framework version to 4.0.0

* [Slim4] Bump required PHP version to 7.1

[Upgrade Guide](https://www.slimframework.com/docs/v4/start/upgrade.html)

* [Slim4] Remove app settings

Slim’s App settings used to be a part of the container and  they have
now been decoupled from it.

[Upgrade Guide](https://www.slimframework.com/docs/v4/start/upgrade.html)

* [Slim4] Set container argument optional

Slim uses an optional dependency container to prepare, manage,
and inject application dependencies.
Slim supports containers that implement PSR-11
like [PHP-DI](http://php-di.org/doc/frameworks/slim.html).

[Upgrade Guide](https://www.slimframework.com/docs/v4/start/upgrade.html)

* [Slim4] Change response body write

You can't write to response instance directly anymore,
need to retrieve body object first.

[Doc](https://www.slimframework.com/docs/v4/objects/response.html#the-response-body)

* [Slim4] Change Slim\App constructor

[Upgrade Guide](https://www.slimframework.com/docs/v4/start/upgrade.html)

* [Slim4] Refactor token authentication options

User can provide array or Container as constructor argument from now.
Small refactoring required to retrieve authentication options from
that argument.

* [Slim4] Add PSR-7 implementation codegen flags

This approach seems more flexible to me.
User can customize templates in favor of chosen PSR7 implementation.
It's easier to change Composer packages and their versions.

* [Slim4] Add JsonBodyParserMiddleware

Slim4 doesn't parse JSON body, need to add suggested middleware.
Ref: https://www.slimframework.com/docs/v4/objects/request.html#the-request-body

* [Slim4] Remove request's deprecated methods usage

Since Slim 4.0.0 ServerRequest implementation doesn't have
getQueryParam and getParsedBodyParam methods anymore.

* [Slim4] Use getUploadedFiles for multipart request

isMultipart codegen property is always false so far.
Hope that bug will be fixed soon.

* [Slim4] Add samples
2019-10-21 22:20:12 +08:00