Skip to content

Commit

Permalink
add typescript server generator
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskapp committed Aug 17, 2024
1 parent bca5999 commit 5a73b2a
Show file tree
Hide file tree
Showing 57 changed files with 1,656 additions and 3 deletions.
31 changes: 31 additions & 0 deletions src/Generator/Server/Dto/Context.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/*
* PSX is an open source PHP framework to develop RESTful APIs.
* For the current version and information visit <https://phpsx.org>
*
* Copyright 2010-2024 Christoph Kappestein <christoph.kappestein@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

namespace PSX\Api\Generator\Server\Dto;

/**
* @author Christoph Kappestein <christoph.kappestein@gmail.com>
* @license http://www.apache.org/licenses/LICENSE-2.0
* @link https://phpsx.org
* @extends \ArrayObject<string, mixed>
*/
class Context extends \ArrayObject
{
}
58 changes: 58 additions & 0 deletions src/Generator/Server/Dto/File.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php
/*
* PSX is an open source PHP framework to develop RESTful APIs.
* For the current version and information visit <https://phpsx.org>
*
* Copyright 2010-2024 Christoph Kappestein <christoph.kappestein@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

namespace PSX\Api\Generator\Server\Dto;

use PSX\Api\OperationInterface;

/**
* @author Christoph Kappestein <christoph.kappestein@gmail.com>
* @license http://www.apache.org/licenses/LICENSE-2.0
* @link https://phpsx.org
*/
class File
{
private string $name;
private array $operations;

public function __construct(string $name)
{
$this->name = $name;
$this->operations = [];
}

public function getName(): string
{
return $this->name;
}

/**
* @return array<string, OperationInterface>
*/
public function getOperations(): array
{
return $this->operations;
}

public function addOperation(string $name, OperationInterface $operation): void
{
$this->operations[$name] = $operation;
}
}
80 changes: 80 additions & 0 deletions src/Generator/Server/Dto/Folder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php
/*
* PSX is an open source PHP framework to develop RESTful APIs.
* For the current version and information visit <https://phpsx.org>
*
* Copyright 2010-2024 Christoph Kappestein <christoph.kappestein@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

namespace PSX\Api\Generator\Server\Dto;

/**
* @author Christoph Kappestein <christoph.kappestein@gmail.com>
* @license http://www.apache.org/licenses/LICENSE-2.0
* @link https://phpsx.org
*/
class Folder
{
private array $folders;
private array $files;

public function __construct()
{
$this->folders = [];
$this->files = [];
}

/**
* @return array<string, Folder>
*/
public function getFolders(): array
{
return $this->folders;
}

public function hasFolders(): bool
{
return count($this->folders) > 0;
}

public function addFolder(string $name, Folder $folder): void
{
$this->folders[$name] = $folder;
}

public function getFolder(string $name): ?Folder
{
return $this->folders[$name] ?? null;
}

/**
* @return array<string, File>
*/
public function getFiles(): array
{
return $this->files;
}

public function addFile(string $name, File $file): void
{
$this->files[$name] = $file;
}

public function getFile(string $name): ?File
{
return $this->files[$name] ?? null;
}

}
40 changes: 40 additions & 0 deletions src/Generator/Server/Dto/Type.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php
/*
* PSX is an open source PHP framework to develop RESTful APIs.
* For the current version and information visit <https://phpsx.org>
*
* Copyright 2010-2023 Christoph Kappestein <christoph.kappestein@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

namespace PSX\Api\Generator\Server\Dto;

/**
* Type
*
* @author Christoph Kappestein <christoph.kappestein@gmail.com>
* @license http://www.apache.org/licenses/LICENSE-2.0
* @link https://phpsx.org
*/
class Type
{
public function __construct(
public string $type,
public string $docType,
public bool $isMap = false,
public bool $isArray = false,
)
{
}
}
Loading

0 comments on commit 5a73b2a

Please sign in to comment.