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

add command to generate json schema #2996

Merged
merged 2 commits into from Aug 21, 2019

Conversation

@jockos
Copy link
Contributor

commented Aug 19, 2019

Add a command to generate a JSON Schema for a resource.
Can be used for the whole resource or by operation

Q A
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
License MIT
@dunglas
Copy link
Member

left a comment

Almost good! Just one little more change. The CI must also be green (PHP CS Fixer, PHPStan etc).

src/JsonSchema/Command/JsonSchemaGenerateCommand.php Outdated Show resolved Hide resolved
src/JsonSchema/SchemaFactory.php Outdated Show resolved Hide resolved

@jockos jockos force-pushed the jockos:add-json-schema-generate-command branch 2 times, most recently from 1736836 to 4b9405d Aug 20, 2019

@dunglas
Copy link
Member

left a comment

When the CI will be green!

@jockos jockos force-pushed the jockos:add-json-schema-generate-command branch 7 times, most recently from 49bb11d to 672949c Aug 20, 2019

->setName('api:json-schema:generate')
->setDescription('Generates the JSON Schema for a resource operation.')
->addArgument('resource', InputArgument::REQUIRED, 'The Fully Qualified Class Name (FQCN) of the resource')
->addOption('itemOperation', null, InputOption::VALUE_OPTIONAL, 'The item operation')

This comment has been minimized.

Copy link
@teohhanhui

teohhanhui Aug 20, 2019

Member

All of the InputOption::VALUE_OPTIONAL should actually be InputOption::VALUE_REQUIRED.

From the documentation:

InputOption::VALUE_REQUIRED

This value is required (e.g. --iterations=5 or -i5), the option itself is still optional

This comment has been minimized.

Copy link
@teohhanhui

teohhanhui Aug 20, 2019

Member

Another thing, don't we usually use dashes in option names, not camelCase?

@jockos jockos force-pushed the jockos:add-json-schema-generate-command branch 3 times, most recently from e9436f2 to 91b530e Aug 20, 2019

->addOption('itemOperation', null, InputOption::VALUE_REQUIRED, 'The item operation')
->addOption('collectionOperation', null, InputOption::VALUE_REQUIRED, 'The collection operation')
->addOption('format', null, InputOption::VALUE_REQUIRED, 'The response format', (string) $this->formats[0])
->addOption('type', null, InputOption::VALUE_REQUIRED, 'Use this option to set the type of output', 'input');

This comment has been minimized.

Copy link
@teohhanhui

teohhanhui Aug 20, 2019

Member

Perhaps:

The type of schema to generate (input or output)

@jockos jockos force-pushed the jockos:add-json-schema-generate-command branch 3 times, most recently from 45d4e9d to 8aef8bf Aug 21, 2019

jockos added 2 commits Aug 19, 2019

@jockos jockos force-pushed the jockos:add-json-schema-generate-command branch from 8aef8bf to 6ff741c Aug 21, 2019

@dunglas dunglas merged commit 7ac5857 into api-platform:master Aug 21, 2019

11 checks passed

Scrutinizer Analysis: 5 updated code elements – Tests: passed
Details
SymfonyInsight: dunglas / API Platform Core Code quality OK.
Details
ci/circleci: behat-coverage Your tests passed on CircleCI!
Details
ci/circleci: behat-elasticsearch-coverage Your tests passed on CircleCI!
Details
ci/circleci: behat-mongodb-coverage Your tests passed on CircleCI!
Details
ci/circleci: php-cs-fixer Your tests passed on CircleCI!
Details
ci/circleci: phpstan Your tests passed on CircleCI!
Details
ci/circleci: phpunit-coverage Your tests passed on CircleCI!
Details
ci/circleci: phpunit-mongodb-coverage Your tests passed on CircleCI!
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@dunglas

This comment has been minimized.

Copy link
Member

commented Aug 21, 2019

Thanks @jockos!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.