Codeception icon indicating copy to clipboard operation
Codeception copied to clipboard

Issue #6334 - Add JSONSchema definitions for configuration YAML files

Open Sweetchuck opened this issue 4 years ago • 7 comments

Issue #6334 - Add JSONSchema definitions for configuration YAML files

Sweetchuck avatar Jan 27 '22 10:01 Sweetchuck

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.

Sweetchuck avatar Jan 27 '22 10:01 Sweetchuck

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.

DavertMik avatar Jan 28 '22 22:01 DavertMik

@DavertMik This is how I use it with PhpStorm:

  • https://www.jetbrains.com/help/phpstorm/2021.3/json.html#ws_json_schema_add_custom
  • File | Settings | Languages & Frameworks | Schemas and DTDs | JSON Schema Mappings

Sweetchuck avatar Jan 28 '22 23:01 Sweetchuck

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

Sweetchuck avatar Jan 29 '22 00:01 Sweetchuck

@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.

Sweetchuck avatar Jan 29 '22 11:01 Sweetchuck

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.

Naktibalda avatar Jan 29 '22 13:01 Naktibalda

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

Naktibalda avatar Jan 29 '22 15:01 Naktibalda