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

Issue #6334 - Add JSONSchema definitions for configuration YAML files #6335

Open
wants to merge 1 commit into
base: 4.1
Choose a base branch
from

Conversation

Sweetchuck
Copy link

Issue #6334 - Add JSONSchema definitions for configuration YAML files

@Sweetchuck
Copy link
Author

Sweetchuck commented Jan 27, 2022

Currently it is just a basic "Proof of concept" implementation.
In don't know all the configuration options, and very likely I added some deprecated options as well, such as class_name vs actor in suite definition, but I don't know which one is the correct one.

@DavertMik
Copy link
Member

Thanks @Sweetchuck, this is really good initiative.

How can we trigger the validation for this schema?

I think we need to continue on those, deprecated properties are also ok, we don't often break compatibility on configuration level. We just need to make sure that all cases can be handled by the schema.

@Sweetchuck
Copy link
Author

@DavertMik This is how I use it with PhpStorm:

@Sweetchuck
Copy link
Author

Are there any schema related differences between the ./codeception.dist.yml and a ./tests/my-suite-01.suite.dist.yml?

@Sweetchuck
Copy link
Author

@DavertMik

How can we trigger the validation for this schema?

I don't know the details, but some kind of configuration validation already happening without JSONSchema.

For example:

DEPRECATION: 'settings: bootstrap: fake.php' option is deprecated! Replace it with: 'bootstrap: fake.php' (not under settings section). See: https://codeception.com/docs/reference/Configuration

On other projects I use opis/json-schema to validate a data structure against a JSONSchema.

@Naktibalda
Copy link
Member

Are there any schema related differences between the ./codeception.dist.yml and a ./tests/my-suite-01.suite.dist.yml?

You could take a look at https://github.com/Codeception/Codeception/blob/5.0/src/Codeception/Configuration.php#L77-L126

Settings that can be set under settings key in codeception.yaml, can be set as top level settings in suite configuration files.

# @todo
oneOf:
-
type: 'null'
Copy link
Member

Choose a reason for hiding this comment

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

I'm pretty sure that it doesn't make sense to set optional parameters to null in yaml file.

Copy link
Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Null is the default value in the PHP code, it isn't necessary to set settings to null in yaml file and it can be forbidden.
A more usual approach to omit unnecessary settings.

@Naktibalda
Copy link
Member

Is there some command line tool for validation? It would be nice to have it in CI.

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

Successfully merging this pull request may close these issues.

None yet

3 participants