Minor fixes
This commit is contained in:
parent
4d87d922f6
commit
15f650a6d9
|
@ -18,11 +18,11 @@ jobs:
|
|||
image: sysbot-org/tgscraper:latest
|
||||
options: -v ${{ github.workspace }}:/out
|
||||
run: |
|
||||
'app:export-schema --readable botapi.json'
|
||||
'app:export-schema --yaml --readable botapi.yaml'
|
||||
'app:export-schema --postman --readable botapi_postman.json'
|
||||
'app:export-schema --openapi --readable botapi_openapi.json'
|
||||
'app:export-schema --yaml --openapi --readable botapi_openapi.yaml'
|
||||
'app:export-schema --readable botapi.json'
|
||||
'app:export-schema --yaml --readable botapi.yaml'
|
||||
'app:export-schema --postman --readable botapi_postman.json'
|
||||
'app:export-schema --openapi --readable botapi_openapi.json'
|
||||
'app:export-schema --yaml --openapi --readable botapi_openapi.yaml'
|
||||
- name: Deploy
|
||||
uses: peaceiris/actions-gh-pages@v3
|
||||
with:
|
||||
|
|
|
@ -14,13 +14,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- New `Versions::STABLE` constant: it will automatically return the latest stable version instead of the live version (useful for the cache package).
|
||||
- Added the JSON schema specification for the custom format provided by TGScraper.
|
||||
- Added this changelog.
|
||||
- Added a workflow to automatically generate the bot API schema every day.
|
||||
|
||||
### Changed
|
||||
- The `Generator` class has now been renamed `TgScraper`.
|
||||
- The `required` property in method fields has been replaced by the new `optional` property, for the sake of consistency.
|
||||
- You now need a schema in order to instantiate the `TgScraper` class (don't worry, you can use the new methods `TgScraper::fromUrl` and `TgScraper::fromVersion`).
|
||||
- The `Versions` class constants have been replaced with an actual version string. If you still need the URLs, use the new class constant `Versions::URLS`.
|
||||
- TGScraper will now only return arrays. If you still need JSON or YAML encoding, please use the new `Encoder` class.
|
||||
- TGScraper will now only return arrays. If you still need JSON or YAML encoding, please use the new `Encoder` class.
|
||||
- Default inline value for YAML has been changed to 16.
|
||||
|
||||
### Fixed
|
||||
- Minor improvements to `StubCreator`.
|
||||
|
|
20
README.md
20
README.md
|
@ -19,7 +19,13 @@ Interested in recent changes? Have a look [here](CHANGELOG.md)!
|
|||
Install the library with composer:
|
||||
|
||||
```bash
|
||||
$ composer require sysbot/tgscraper
|
||||
$ composer require sysbot/tgscraper --prefer-stable
|
||||
```
|
||||
|
||||
(Optional) Install the cache package:
|
||||
|
||||
```bash
|
||||
$ composer require sysbot/tgscraper-cache
|
||||
```
|
||||
|
||||
## Using from command line
|
||||
|
@ -56,7 +62,17 @@ Extract the latest schema in YAML format:
|
|||
|
||||
### OpenAPI
|
||||
|
||||
Work in progress.
|
||||
Extract the latest OpenAPI schema in JSON format:
|
||||
|
||||
```bash
|
||||
$ vendor/bin/tgscraper app:export-schema --openapi botapi_openapi.json
|
||||
```
|
||||
|
||||
Or, if you prefer YAML:
|
||||
|
||||
```bash
|
||||
$ vendor/bin/tgscraper app:export-schema --openapi --yaml botapi_openapi.yaml
|
||||
```
|
||||
|
||||
### Stubs
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ class ExportSchemaCommand extends Command
|
|||
InputOption::VALUE_NONE,
|
||||
'Generate a human-readable file (overrides "--inline" and "--indent")'
|
||||
)
|
||||
->addOption('inline', null, InputOption::VALUE_REQUIRED, '(YAML only) Inline level', 12)
|
||||
->addOption('inline', null, InputOption::VALUE_REQUIRED, '(YAML only) Inline level', 16)
|
||||
->addOption('indent', null, InputOption::VALUE_REQUIRED, '(YAML only) Indent level', 4)
|
||||
->addOption('layer', 'l', InputOption::VALUE_REQUIRED, 'Bot API version to use', Versions::LATEST)
|
||||
->addOption(
|
||||
|
@ -99,7 +99,7 @@ class ExportSchemaCommand extends Command
|
|||
$readable = $input->getOption('readable');
|
||||
$options = $input->getOption('options');
|
||||
$useYaml = $input->getOption('yaml');
|
||||
$inline = $readable ? 12 : $input->getOption('inline');
|
||||
$inline = $readable ? 16 : $input->getOption('inline');
|
||||
$indent = $readable ? 4 : $input->getOption('indent');
|
||||
$output->writeln('Saving schema to file...');
|
||||
if ($input->getOption('openapi')) {
|
||||
|
@ -107,7 +107,7 @@ class ExportSchemaCommand extends Command
|
|||
if ($useYaml) {
|
||||
return $this->saveFile($logger, $output, $destination, Encoder::toYaml($data, $inline, $indent, $options));
|
||||
}
|
||||
return $this->saveFile($logger, $output, $destination, Encoder::toJson($data, $options, $readable));
|
||||
return $this->saveFile($logger, $output, $destination, Encoder::toJson($data, $options | JSON_UNESCAPED_SLASHES, $readable));
|
||||
}
|
||||
if ($input->getOption('postman')) {
|
||||
$data = $generator->toPostman();
|
||||
|
|
|
@ -27,7 +27,7 @@ class Encoder
|
|||
* @param int $flags
|
||||
* @return string
|
||||
*/
|
||||
public static function toYaml(mixed $data, int $inline = 12, int $indent = 4, int $flags = 0): string
|
||||
public static function toYaml(mixed $data, int $inline = 16, int $indent = 4, int $flags = 0): string
|
||||
{
|
||||
return Yaml::dump($data, $inline, $indent, $flags);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue