diff --git a/migration.md b/migration.md deleted file mode 100644 index 45f8859..0000000 --- a/migration.md +++ /dev/null @@ -1,196 +0,0 @@ - -# Migration - -The following list covers all major restrictions to JSON Schema. This should help -to migrate your JSON Schema to TypeSchema. Also please take a look at our [migration -tool](https://typeschema.org/migration/jsonschema) which allows you to automatically -convert a JSON Schema into a TypeSchema. - -## No-Type - -### Invalid - -```json -{ -} -``` - -In JsonSchema it is possible to define no keyword which means every value is -valid. - -### Reasoning - -In TypeSchema every schema must be assigned to a specific type depending on the -used keywords so that a parser knows at least which type is expected. Depending -on the type there are specific keywords possible. - -## Array-Type - -### Invalid - -```json -{ - "type": ["string", "number"], - "minLength": 12 -} -``` - -In JsonSchema it is possible to allow multiple types at the `type` keyword. - -### Reasoning - -In TypeSchema `type` must be a `string` since based on this schema it is -impossible to generate a strongly typed class. To allow different types you -need to explicit use an union type (`oneOf` keyword) - -## Array-Array-Item - -### Invalid - -```json -{ - "type": "array", - "items": { - "type": "array" - } -} -``` - -In JsonSchema it is possible to use every schema as array item. - -### Reasoning - -In TypeSchema it is not possible to use an array as array value. This is done -because this constructs complicates code generators and it is also bad data -design. - -## Null-Type - -### Invalid - -```json -{ - "type": "null" -} -``` - -In JsonSchema it is possible to define the `null` type. - -### Reasoning - -We think that `null` is not a data type but rather an attribute of a type. -Because of that TypeSchema has the `nullable` keyword which can be `true` or -`false` for every type. - -## Mixed-Assertions - -### Invalid - -```json -{ - "type": "string", - "minLength": 12, - "minimum": 12 -} -``` - -In JsonSchema it is possible to define multiple assertions for different types. - -### Reasoning - -Since in TypeSchema you can define only one type, you can also use only the -assertions which are fitting for the type. I.e. `minimum` for the `number` type -or `minLength` for the `string` type but not both. - -## Pattern-Properties - -### Invalid - -```json -{ - "type": "object", - "patternProperties": { - "^S_": { - "type": "string" - }, - "^I_": { - "type": "integer" - } - } -} -``` - -In JsonSchema it is possible to use pattern properties to apply different -schemas based on the key. - -### Reasoning - -In TypeSchema you need to decide between a struct or map. A struct contains -hardcoded properties through the `properties` keyword and a map makes use of the -`additionalProperties` keyword. For the `additionalProperties` keyword every value -must follow the same schema. Code generators can not usefully understand those -properties and we think also that the `patternProperties` keyword promotes -bad data design. - -## Root-Object - -### Invalid - -```json -{ - "type": "object", - "properties": { - "foo": { - "type": "string" - } - } -} -``` - -### Reasoning - -In JsonSchema you can define a root schema at the top level. In TypeSchema we -can only use a `$ref` at the root level to reference a root schema. This is -because we always need a name for every schema and this is the key at the -`definitions` location. The following example shows a valid version: - -### Valid - -```json -{ - "definitions": { - "MyType": { - "type": "object", - "properties": { - "foo": { - "type": "string" - } - } - } - }, - "$ref": "MyType" -} -``` - -## Anyof-Type - -### Invalid - -```json -{ - "anyOf": [{ - "type": "string" - },{ - "type": "number" - }] -} -``` - -In JsonSchema it is possible to use the `anyOf` keyword. In TypeSchema this -keyword does not exist. You can use either `oneOf` or `allOf`. - -### Reasoning - -The `anyOf` keyword is not practical for code generation. The `oneOf` type can -be mapped to a union type and the `allOf` type can be mapped to an intersection -type. diff --git a/www/resources/template/ecosystem.php b/www/resources/template/ecosystem.php index febc94a..eb0c26c 100644 --- a/www/resources/template/ecosystem.php +++ b/www/resources/template/ecosystem.php @@ -9,11 +9,17 @@

Ecosystem

-

The following page lists integrations, projects and libraries related to TypeSchema.

+

The following page lists integrations, libraries and other projects related to TypeSchema.

+

Integration

- -

Project

- +

+ + + + + + + + + + + + + + + + + + + + + + + + + +
NameGitHubLink
DockerGitHubDocker
GitHub ActionGitHubMarketplace
+

Library

- +

+ + + + + + + + + + + + + + + + + +
NameDescription
psx-schemaA PHP library to parse and validate TypeSchema specifications
+ +

Frontend

+

+ + + + + + + + + + + + + + + + + +
NameDescription
ngx-typeschema-editorAn Angular component to visual edit a TypeSchema
+ +

Project

+

+ + + + + + + + + + + + + + + + + + + + + + + + + +
NameDescription
TypeHubA service to manage and share TypeSchema specifications
TypeAPIAn OpenAPI alternative to describe REST APIs for type-safe code generation
SDKgenA service to generate client SDKs
Edit this page diff --git a/www/resources/template/faq.php b/www/resources/template/faq.php deleted file mode 100644 index ffdff82..0000000 --- a/www/resources/template/faq.php +++ /dev/null @@ -1,77 +0,0 @@ - - - - - -
-

FAQ

- -
-

What is the history?

-

We are the developers behind Fusio an open source API management - system. We wanted to build an SDK generator for different languages, which builds an SDK based on the - available schema. During this we have experienced the limitations of JSON Schema for code generators. Because of this - we have started to develop TypeSchema. A JSON format which can be easily transformed into code and also other - specification formats.

- -
-

What is your vision?

-

We envision a future where the code generation ecosystem just works. That means a user gets an TypeAPI document and - he is able to use this document to generate high quality code for either client or server implementations.

- -
-

How does the website work?

-

The complete website is also opensource, you can check out our repository - and take a look at the www folder, there is all code related to the website placed. If you want to take a look at the - code generator you can check out the generator repository.

- -
-

I have a question regarding the project?

-

You can contact us directly in case you have a question regarding - the project, or you can also take a look at our repository.

- -
-

Where can I get more information?

-

In our mission to improve code generation we write articles explaining our thoughts and background regarding - TypeSchema and the hole API and code generation ecosystem. If you are interested you can take a look at the following - articles:

- - -
-

What is the difference to JSON Schema?

- -

JSON Schema is a constraint system - which is designed to validate JSON data. Such a constraint system is not great for code generation, with TypeSchema - our focus is to model data to be able to generate high quality code.

- -

For code generators it is difficult to work with JSON Schema since it is designed to validate JSON data. In JSON - Schema you dont need to provide any keywords i.e. {} is a valid JSON Schema which basically allows every - value and the defined keywords are applied based on the actual data. This means you can interpret a schema only if you - have also the actual data. A code generator on the other hand needs to determine a concrete type of a schema without - the actual data.

- -

JSON Schema has many keywords which contain logic like dependencies, not, - if/then/else which are basically not needed for code generators and really complicates building them. We - have also explained some pitfalls in our - migration document.

- -

TypeSchema does not work with JSON pointer. In TypeSchema you reference every type simply by the name i.e. - Student. In JSON Schema you need to provide the path i.e. #/definitions/Student to the - schema. In TypeSchema you can also reference only local types. If you want to import a remote schema you need to - explicit declare it via $import.

- - -
- - diff --git a/www/resources/template/generator.php b/www/resources/template/generator.php index 25ddb62..ba725d1 100644 --- a/www/resources/template/generator.php +++ b/www/resources/template/generator.php @@ -3,52 +3,28 @@ -
-

DTO Generator

+
+

DTO Generator

+

This list gives you access to the reference code generator implementation. + To prevent misuse the code generator is protected by recaptcha, if you want to invoke the code generator + programmatically please take a look at the SDKgen project + which offers various integration options like an CLI, GitHub action or REST API. +

-
-
-
- + +
+
+ $typeTitle): ?> + +
-
- -
- - -
-
- -
- - - -
-
- - $chunk): ?> -
-

-
-
- - -
-

Output

-
- - -
+
- - - - diff --git a/www/resources/template/generator/form.php b/www/resources/template/generator/form.php new file mode 100644 index 0000000..5bb56ac --- /dev/null +++ b/www/resources/template/generator/form.php @@ -0,0 +1,54 @@ + + + + + +
+

DTO Generator

+
+
+
+
+ +
+
+ +
+ +
+
+
+ +
+ + + +
+
+ + $chunk): ?> +
+

+
+
+ + +
+

Output

+
+
+ + +
+
+
+ + + + + + diff --git a/www/resources/template/generator_overview.php b/www/resources/template/generator_overview.php deleted file mode 100644 index de92b35..0000000 --- a/www/resources/template/generator_overview.php +++ /dev/null @@ -1,30 +0,0 @@ - - - - - -
-

DTO Generator

-

This list gives you access to our reference code generator implementation. - To prevent misuse the code generator is protected by recaptcha, if you want to invoke the code generator - programmatically please take a look at the SDKgen project - which offers various integration options like an CLI, GitHub action or REST API. -

-
- -
-
- $typeTitle): ?> - - -
-
- -
-
- - diff --git a/www/resources/template/hash.php b/www/resources/template/hash.php deleted file mode 100644 index 06a10be..0000000 --- a/www/resources/template/hash.php +++ /dev/null @@ -1,34 +0,0 @@ - - - - - -
-

Hash

- -
-
-
-
- - -
- -
-
-
-
-
-
-
- - - - diff --git a/www/resources/template/history.php b/www/resources/template/history.php new file mode 100644 index 0000000..d5e0237 --- /dev/null +++ b/www/resources/template/history.php @@ -0,0 +1,71 @@ + + + + + +
+

History

+

TypeSchema has evolved out of the need to build a solid code generator for a Swagger/OpenAPI specification. + During this development process we have experienced problems + and tried to find a way to solve them. At the beginning we had only defined some "stricter" rules for a JSON Schema to make it easier + for code generators but over time this has evolved into a complete separate specification. TypeSchema provides a solid way + to model JSON payload and a great code generator to automatically generate DTOs + to represent this JSON data.

+ +
+
+

If you ask yourself, why do I need a specification to model my JSON payload,
then there is only a simple answer: type-safety.

+
+
+ +

If we look at the history of programming

+ +

Thought model

+

TypeSchema has a specific thought model which fits perfectly with classical OOP languages like Java, C#, PHP or TypeScript. + But it supports also languages like Go, which have a different approach. In this case the generator will try to apply these concepts on + generation so that you can still use them at the specification. For example Go does not support inheritance, in this case the code generator + copies all inherited properties into the structure.

+ +
    +
  • TypeSchema is designed to model data structures
  • +
  • TypeSchema abstracts OOP concepts like inheritance, polymorphism and generics
  • +
  • TypeSchema is code-first, this means it is easy possible to generate a TypeSchema through reflection without additional annotations
  • +
  • TypeSchema has no keywords to validate data
  • +
+ +

What is the difference to JSON Schema?

+

JSON Schema is a constraint system + which is designed to validate JSON data. Such a constraint system is not great for code generation, with TypeSchema + our focus is to model data to be able to generate high quality code.

+ +

For code generators it is difficult to work with JSON Schema since it is designed to validate JSON data. In JSON + Schema you dont need to provide any keywords i.e. {} is a valid JSON Schema which basically allows every + value and the defined keywords are applied based on the actual data. This means you can interpret a schema only if you + have also the actual data. A code generator on the other hand needs to determine a concrete type of a schema without + the actual data.

+ +

JSON Schema has many keywords which contain logic like dependencies, not, + if/then/else which are basically not needed for code generators and really complicates building them.

+ +

TypeSchema does not work with JSON pointer. In TypeSchema you reference every type simply by the name i.e. + Student. In JSON Schema you need to provide the path i.e. #/definitions/Student to the + schema. In TypeSchema you can also reference only local types. If you want to import a remote schema you need to + explicit declare it via import.

+ +

I have a problem with the generated code?

+

In case there are problems with the generated code you can always create an issue at our repository.

+ +

I have a question regarding the project?

+

You can contact us directly in case you have a question regarding + the project, or you can also take a look at our repository.

+ + +
+ + diff --git a/www/resources/template/inc/header.php b/www/resources/template/inc/header.php index 23065c6..dc3d087 100644 --- a/www/resources/template/inc/header.php +++ b/www/resources/template/inc/header.php @@ -41,17 +41,10 @@ function gtag(){dataLayer.push(arguments);} Ecosystem - GitHub logo diff --git a/www/resources/template/index.php b/www/resources/template/index.php index 9cdcf6d..8a545cb 100644 --- a/www/resources/template/index.php +++ b/www/resources/template/index.php @@ -8,7 +8,7 @@

Specification Editor - Generator + Generator

@@ -31,7 +31,7 @@

-

Programming Languages

+

Examples

At the following list you can take a look at example output for each supported programming language.

diff --git a/www/resources/template/specification.php b/www/resources/template/specification.php index f8c9cfa..306b8e1 100644 --- a/www/resources/template/specification.php +++ b/www/resources/template/specification.php @@ -8,11 +8,8 @@
-

Specification

-
-

Table of Contents

  • Introduction
  • diff --git a/www/resources/template/tools.php b/www/resources/template/tools.php new file mode 100644 index 0000000..37ab9f9 --- /dev/null +++ b/www/resources/template/tools.php @@ -0,0 +1,31 @@ + + + + + +
    +

    Tools

    +

    We provide several tools which can help to migrate from an external specification or generate specific output based on an existing to TypeSchema specification.

    +
    +
    +
    +
  • Migration
  • + JSON + JSON Schema + OpenAPI +
    +
    +
    +
    +
  • Generate
  • + Changelog +
    +
    +
    +
    + + diff --git a/www/resources/template/changelog.php b/www/resources/template/tools/changelog.php similarity index 79% rename from www/resources/template/changelog.php rename to www/resources/template/tools/changelog.php index 68a8ceb..b425d3b 100644 --- a/www/resources/template/changelog.php +++ b/www/resources/template/tools/changelog.php @@ -1,17 +1,16 @@ - +

    Changelog

    - +

    Through this form you can generate a changelog between two TypeSchema versions.

    +
    @@ -49,4 +48,4 @@
    - + diff --git a/www/resources/template/migration/json.php b/www/resources/template/tools/json.php similarity index 86% rename from www/resources/template/migration/json.php rename to www/resources/template/tools/json.php index 57bcb95..bf16a05 100644 --- a/www/resources/template/migration/json.php +++ b/www/resources/template/tools/json.php @@ -3,16 +3,17 @@

    JSON

    - +

    +
    diff --git a/www/resources/template/migration/jsonschema.php b/www/resources/template/tools/jsonschema.php similarity index 86% rename from www/resources/template/migration/jsonschema.php rename to www/resources/template/tools/jsonschema.php index d2c815b..56eaddc 100644 --- a/www/resources/template/migration/jsonschema.php +++ b/www/resources/template/tools/jsonschema.php @@ -3,17 +3,18 @@

    JSON Schema

    - +

    +
    diff --git a/www/resources/template/migration/openapi.php b/www/resources/template/tools/openapi.php similarity index 85% rename from www/resources/template/migration/openapi.php rename to www/resources/template/tools/openapi.php index 3bf091b..64c479c 100644 --- a/www/resources/template/migration/openapi.php +++ b/www/resources/template/tools/openapi.php @@ -3,16 +3,17 @@

    OpenAPI

    - +

    +
    diff --git a/www/src/Controller/Generator.php b/www/src/Controller/Generator.php index da0b2ef..079c0cb 100644 --- a/www/src/Controller/Generator.php +++ b/www/src/Controller/Generator.php @@ -49,7 +49,7 @@ public function show(): mixed 'types' => array_chunk($types, 9, true), ]; - $templateFile = __DIR__ . '/../../resources/template/generator_overview.php'; + $templateFile = __DIR__ . '/../../resources/template/generator.php'; return new Template($data, $templateFile, $this->reverseRouter); } @@ -72,7 +72,7 @@ public function showType(string $type): mixed 'recaptcha_key' => $this->config->get('recaptcha_key'), ]; - $templateFile = __DIR__ . '/../../resources/template/generator.php'; + $templateFile = __DIR__ . '/../../resources/template/generator/form.php'; return new Template($data, $templateFile, $this->reverseRouter); } @@ -112,7 +112,7 @@ public function generate(string $type, Generate $generate): mixed 'recaptcha_key' => $this->config->get('recaptcha_key'), ]; - $templateFile = __DIR__ . '/../../resources/template/generator.php'; + $templateFile = __DIR__ . '/../../resources/template/generator/form.php'; return new Template($data, $templateFile, $this->reverseRouter); } diff --git a/www/src/Controller/Hash.php b/www/src/Controller/Hash.php deleted file mode 100644 index 8d8f9cb..0000000 --- a/www/src/Controller/Hash.php +++ /dev/null @@ -1,83 +0,0 @@ - 'Hash | TypeSchema', - 'method' => explode('::', __METHOD__), - 'schema' => $this->getSchema(), - ]; - - $templateFile = __DIR__ . '/../../resources/template/hash.php'; - return new Template($data, $templateFile, $this->reverseRouter); - } - - #[Post] - #[Path('/hash')] - public function generate(Generate $generate): mixed - { - $schema = $generate->getSchema() ?? throw new \RuntimeException('Provided no schema'); - - try { - $result = (new TypeSchema($this->schemaManager))->parse($schema); - $output = (new Inspector\Hash())->generate($result->getDefinitions()); - } catch (\Throwable $e) { - $output = $e->getMessage(); - } - - $data = [ - 'method' => explode('::', __METHOD__), - 'schema' => $this->getSchema(), - 'output' => $output - ]; - - $templateFile = __DIR__ . '/../../resources/template/hash.php'; - return new Template($data, $templateFile, $this->reverseRouter); - } - - private function getSchema(): string - { - return <<<'JSON' -{ - "definitions": { - "Student": { - "type": "object", - "properties": { - "firstName": { - "type": "string" - }, - "lastName": { - "type": "string" - }, - "age": { - "type": "integer" - } - } - } - }, - "$ref": "Student" -} -JSON; - } -} diff --git a/www/src/Controller/History.php b/www/src/Controller/History.php new file mode 100644 index 0000000..3ae1ee6 --- /dev/null +++ b/www/src/Controller/History.php @@ -0,0 +1,29 @@ + 'History | TypeSchema', + 'method' => explode('::', __METHOD__), + ]; + + $templateFile = __DIR__ . '/../../resources/template/history.php'; + return new Template($data, $templateFile, $this->reverseRouter); + } +} diff --git a/www/src/Controller/Faq.php b/www/src/Controller/Tools.php similarity index 74% rename from www/src/Controller/Faq.php rename to www/src/Controller/Tools.php index 61c9e59..2fde95f 100644 --- a/www/src/Controller/Faq.php +++ b/www/src/Controller/Tools.php @@ -8,22 +8,22 @@ use PSX\Framework\Http\Writer\Template; use PSX\Framework\Loader\ReverseRouter; -class Faq extends ControllerAbstract +class Tools extends ControllerAbstract { public function __construct(private ReverseRouter $reverseRouter) { } #[Get] - #[Path('/faq')] + #[Path('/tools')] public function show(): mixed { $data = [ - 'title' => 'FAQ | TypeSchema', + 'title' => 'Tools | TypeSchema', 'method' => explode('::', __METHOD__), ]; - $templateFile = __DIR__ . '/../../resources/template/faq.php'; + $templateFile = __DIR__ . '/../../resources/template/tools.php'; return new Template($data, $templateFile, $this->reverseRouter); } } diff --git a/www/src/Controller/Changelog.php b/www/src/Controller/Tools/Changelog.php similarity index 87% rename from www/src/Controller/Changelog.php rename to www/src/Controller/Tools/Changelog.php index 1a5cd3c..f0918e5 100644 --- a/www/src/Controller/Changelog.php +++ b/www/src/Controller/Tools/Changelog.php @@ -1,6 +1,6 @@ [] ]; - $templateFile = __DIR__ . '/../../resources/template/changelog.php'; + $templateFile = __DIR__ . '/../../../resources/template/tools/changelog.php'; return new Template($data, $templateFile, $this->reverseRouter); } #[Post] - #[Path('/changelog')] + #[Path('/tools/changelog')] public function generate(Diff $diff): mixed { $left = $diff->getLeft() ?? throw new \RuntimeException('Provided no left'); @@ -55,13 +55,14 @@ public function generate(Diff $diff): mixed } $data = [ + 'title' => 'Changelog | TypeSchema', 'method' => explode('::', __METHOD__), 'left' => $left, 'right' => $right, 'messages' => $messages ]; - $templateFile = __DIR__ . '/../../resources/template/changelog.php'; + $templateFile = __DIR__ . '/../../../resources/template/tools/changelog.php'; return new Template($data, $templateFile, $this->reverseRouter); } @@ -71,7 +72,7 @@ private function getLeft(): string { "definitions": { "Student": { - "type": "object", + "type": "struct", "properties": { "firstName": { "type": "string" @@ -85,7 +86,7 @@ private function getLeft(): string } } }, - "$ref": "Student" + "root": "Student" } JSON; } @@ -97,7 +98,7 @@ private function getRight(): string "definitions": { "Student": { "description": "Represents a student", - "type": "object", + "type": "struct", "properties": { "firstName": { "type": "string" @@ -114,7 +115,7 @@ private function getRight(): string } } }, - "$ref": "Student" + "root": "Student" } JSON; } diff --git a/www/src/Controller/Migration/Json.php b/www/src/Controller/Tools/Json.php similarity index 83% rename from www/src/Controller/Migration/Json.php rename to www/src/Controller/Tools/Json.php index ba8b4c1..d7dc49e 100644 --- a/www/src/Controller/Migration/Json.php +++ b/www/src/Controller/Tools/Json.php @@ -1,6 +1,6 @@ 'JSON migration | TypeSchema', 'method' => explode('::', __METHOD__), 'schema' => $this->getSchema() ]; - $templateFile = __DIR__ . '/../../../resources/template/migration/json.php'; + $templateFile = __DIR__ . '/../../../resources/template/tools/json.php'; return new Template($data, $templateFile, $this->reverseRouter); } #[Post] - #[Path('/migration/json')] + #[Path('/tools/json')] public function migrate(Generate $generate): mixed { $schema = $generate->getSchema() ?? throw new \RuntimeException('Provided no schema'); try { $definitions = []; - $root = $this->transform(json_decode($schema), $definitions); + $root = new \stdClass(); + $schema = $this->transform(json_decode($schema), $definitions); if (count($definitions) > 0) { $root->definitions = (object) $definitions; } + if (isset($schema->target)) { + $root->root = $schema->target; + } + $output = $root; } catch (\Throwable $e) { $output = $e->getMessage(); } $data = [ + 'title' => 'JSON migration | TypeSchema', 'method' => explode('::', __METHOD__), 'schema' => $this->getSchema(), 'output' => json_encode($output, JSON_PRETTY_PRINT) ]; - $templateFile = __DIR__ . '/../../../resources/template/migration/json.php'; + $templateFile = __DIR__ . '/../../../resources/template/tools/json.php'; return new Template($data, $templateFile, $this->reverseRouter); } @@ -71,12 +78,13 @@ private function transform(mixed $schema, array &$definitions): object $name = 'Schema' . substr(sha1(json_encode($properties)), 0, 8); $definitions[$name] = (object) [ - 'type' => 'object', + 'type' => 'struct', 'properties' => $properties, ]; return (object) [ - '$ref' => $name, + 'type' => 'reference', + 'target' => $name, ]; } elseif (is_array($schema)) { if (count($schema) === 0) { @@ -87,7 +95,7 @@ private function transform(mixed $schema, array &$definitions): object return (object) [ 'type' => 'array', - 'items' => $items, + 'schema' => $items, ]; } elseif (is_string($schema)) { return (object) [ @@ -120,6 +128,10 @@ private function getSchema(): string "productName": "foobar", "price": 12.99, "tags": ["foo", "bar"], + "persons": [{ + "firstName": "foo", + "lastName": "bar" + }], "dimensions": { "length": 0, "width": 0, diff --git a/www/src/Controller/Migration/JsonSchema.php b/www/src/Controller/Tools/JsonSchema.php similarity index 90% rename from www/src/Controller/Migration/JsonSchema.php rename to www/src/Controller/Tools/JsonSchema.php index f347d1c..f982444 100644 --- a/www/src/Controller/Migration/JsonSchema.php +++ b/www/src/Controller/Tools/JsonSchema.php @@ -1,6 +1,6 @@ 'JSON Schema migration | TypeSchema', 'method' => explode('::', __METHOD__), 'schema' => $this->getSchema() ]; - $templateFile = __DIR__ . '/../../../resources/template/migration/jsonschema.php'; + $templateFile = __DIR__ . '/../../../resources/template/tools/jsonschema.php'; return new Template($data, $templateFile, $this->reverseRouter); } #[Post] - #[Path('/migration/jsonschema')] + #[Path('/tools/jsonschema')] public function migrate(Generate $generate): mixed { $schema = $generate->getSchema() ?? throw new \RuntimeException('Provided no schema'); @@ -44,12 +45,13 @@ public function migrate(Generate $generate): mixed } $data = [ + 'title' => 'JSON Schema migration | TypeSchema', 'method' => explode('::', __METHOD__), 'schema' => $this->getSchema(), 'output' => json_encode($output, JSON_PRETTY_PRINT) ]; - $templateFile = __DIR__ . '/../../../resources/template/migration/jsonschema.php'; + $templateFile = __DIR__ . '/../../../resources/template/tools/jsonschema.php'; return new Template($data, $templateFile, $this->reverseRouter); } diff --git a/www/src/Controller/Migration/OpenAPI.php b/www/src/Controller/Tools/OpenAPI.php similarity index 95% rename from www/src/Controller/Migration/OpenAPI.php rename to www/src/Controller/Tools/OpenAPI.php index ad6bb86..1d835f7 100644 --- a/www/src/Controller/Migration/OpenAPI.php +++ b/www/src/Controller/Tools/OpenAPI.php @@ -1,6 +1,6 @@ 'OpenAPI migration | TypeSchema', 'method' => explode('::', __METHOD__), 'schema' => $this->getSchema() ]; - $templateFile = __DIR__ . '/../../../resources/template/migration/openapi.php'; + $templateFile = __DIR__ . '/../../../resources/template/tools/openapi.php'; return new Template($data, $templateFile, $this->reverseRouter); } #[Post] - #[Path('/migration/openapi')] + #[Path('/tools/openapi')] public function migrate(Generate $generate): mixed { $schema = $generate->getSchema() ?? throw new \RuntimeException('Provided no schema'); @@ -44,12 +45,13 @@ public function migrate(Generate $generate): mixed } $data = [ + 'title' => 'OpenAPI migration | TypeSchema', 'method' => explode('::', __METHOD__), 'schema' => $this->getSchema(), 'output' => json_encode($output, JSON_PRETTY_PRINT), ]; - $templateFile = __DIR__ . '/../../../resources/template/migration/openapi.php'; + $templateFile = __DIR__ . '/../../../resources/template/tools/openapi.php'; return new Template($data, $templateFile, $this->reverseRouter); }