From f5c0eb6e2c44719bdead3bef465633e8d1120b62 Mon Sep 17 00:00:00 2001 From: Sean Molenaar Date: Sat, 25 Jul 2020 20:36:54 +0200 Subject: [PATCH 1/3] Move to twig --- .gitignore | 2 +- build.xml | 29 +- composer.json | 7 +- composer.lock | 1217 +++- phpdraft | 13 +- .../Model/Elements/BasicStructureElement.php | 4 +- .../Model/Elements/ObjectStructureElement.php | 7 +- .../Tests/ArrayStructureElementTest.php | 2 +- .../Tests/BasicStructureElementTest.php | 2 +- .../Tests/EnumStructureElementTest.php | 2 +- .../Tests/ObjectStructureElementTest.php | 4 +- .../Elements/Tests/RequestBodyElementTest.php | 4 +- src/PHPDraft/Model/HTTPRequest.php | 21 +- src/PHPDraft/Model/HTTPResponse.php | 17 +- src/PHPDraft/Model/HierarchyElement.php | 3 +- src/PHPDraft/Model/Tests/HTTPRequestTest.php | 99 +- src/PHPDraft/Model/Tests/HTTPResponseTest.php | 101 +- .../Model/Tests/HierarchyElementTest.php | 4 +- src/PHPDraft/Model/Transition.php | 46 +- ...Generator.php => BaseTemplateRenderer.php} | 8 +- src/PHPDraft/Out/HTML/default.phtml | 335 - src/PHPDraft/Out/HTML/default/category.twig | 11 + .../HTML/{default.css => default/main.css} | 8 +- .../Out/HTML/{default.js => default/main.js} | 0 src/PHPDraft/Out/HTML/default/main.twig | 82 + src/PHPDraft/Out/HTML/default/nav.twig | 33 + src/PHPDraft/Out/HTML/default/resource.twig | 27 + src/PHPDraft/Out/HTML/default/structure.twig | 32 + src/PHPDraft/Out/HTML/default/transition.twig | 154 + src/PHPDraft/Out/HTML/material.css | 167 - src/PHPDraft/Out/HTML/material.phtml | 269 - src/PHPDraft/Out/HTML/material/category.twig | 11 + src/PHPDraft/Out/HTML/material/main.css | 242 + .../HTML/{material.js => material/main.js} | 40 +- src/PHPDraft/Out/HTML/material/main.twig | 90 + src/PHPDraft/Out/HTML/material/nav.twig | 31 + src/PHPDraft/Out/HTML/material/resource.twig | 27 + src/PHPDraft/Out/HTML/material/structure.twig | 32 + .../Out/HTML/material/transition.twig | 157 + src/PHPDraft/Out/Minifier.php | 393 - ...lateGenerator.php => TemplateRenderer.php} | 213 +- ...ratorTest.php => TemplateRendererTest.php} | 43 +- src/PHPDraft/Out/TwigFactory.php | 69 + src/PHPDraft/Parse/BaseHtmlGenerator.php | 36 +- src/PHPDraft/Parse/HtmlGenerator.php | 28 +- .../Parse/Tests/HtmlGeneratorTest.php | 15 +- tests/phpunit.xml | 2 +- tests/statics/drafter/html/basic.html | 6444 ++++++++--------- tests/statics/drafter/html/material.html | 5663 +++++++++------ tests/statics/full_test.apib | 34 + 50 files changed, 8734 insertions(+), 7546 deletions(-) rename src/PHPDraft/Out/{BaseTemplateGenerator.php => BaseTemplateRenderer.php} (88%) delete mode 100644 src/PHPDraft/Out/HTML/default.phtml create mode 100644 src/PHPDraft/Out/HTML/default/category.twig rename src/PHPDraft/Out/HTML/{default.css => default/main.css} (96%) rename src/PHPDraft/Out/HTML/{default.js => default/main.js} (100%) create mode 100644 src/PHPDraft/Out/HTML/default/main.twig create mode 100644 src/PHPDraft/Out/HTML/default/nav.twig create mode 100644 src/PHPDraft/Out/HTML/default/resource.twig create mode 100644 src/PHPDraft/Out/HTML/default/structure.twig create mode 100644 src/PHPDraft/Out/HTML/default/transition.twig delete mode 100644 src/PHPDraft/Out/HTML/material.css delete mode 100644 src/PHPDraft/Out/HTML/material.phtml create mode 100644 src/PHPDraft/Out/HTML/material/category.twig create mode 100644 src/PHPDraft/Out/HTML/material/main.css rename src/PHPDraft/Out/HTML/{material.js => material/main.js} (59%) create mode 100644 src/PHPDraft/Out/HTML/material/main.twig create mode 100644 src/PHPDraft/Out/HTML/material/nav.twig create mode 100644 src/PHPDraft/Out/HTML/material/resource.twig create mode 100644 src/PHPDraft/Out/HTML/material/structure.twig create mode 100644 src/PHPDraft/Out/HTML/material/transition.twig delete mode 100644 src/PHPDraft/Out/Minifier.php rename src/PHPDraft/Out/{TemplateGenerator.php => TemplateRenderer.php} (50%) rename src/PHPDraft/Out/Tests/{TemplateGeneratorTest.php => TemplateRendererTest.php} (78%) create mode 100644 src/PHPDraft/Out/TwigFactory.php diff --git a/.gitignore b/.gitignore index 613072d6..4737429c 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,4 @@ atlassian-ide-plugin.xml *.pem -index.html \ No newline at end of file +/index.html diff --git a/build.xml b/build.xml index a6b12a83..5118c04e 100644 --- a/build.xml +++ b/build.xml @@ -1,5 +1,5 @@ - + @@ -51,6 +51,7 @@ + @@ -75,6 +76,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/composer.json b/composer.json index 90761a02..67434f97 100644 --- a/composer.json +++ b/composer.json @@ -24,11 +24,14 @@ "michelf/php-markdown": "~1.9", "lukasoppermann/http-status": "~2.0", "ext-json": "*", - "ext-curl": "*" + "ext-curl": "*", + "twig/twig": "^3.0", + "twig/markdown-extra": "^3.0", + "matthiasmullie/minify": "^1.3" }, "require-dev": { "lunr/halo": "dev-master", - "phpunit/phpunit": "~8.0", + "phpunit/phpunit": "~9.0", "theseer/autoload": "~1.0", "phing/phing": "~2.0", "phpstan/phpstan-phpunit": "^0.12.6", diff --git a/composer.lock b/composer.lock index f5e7329f..12f2f176 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "823ee9f84b96f20cb4db7f6b21eb111b", + "content-hash": "cef77d685f965805646c3f88d2417d06", "packages": [ { "name": "lukasoppermann/http-status", @@ -47,9 +47,9 @@ "authors": [ { "name": "Lukas Oppermann", + "role": "Developer", "email": "lukas@vea.re", - "homepage": "http://vea.re", - "role": "Developer" + "homepage": "http://vea.re" } ], "description": "A minimal package for working with HTTP statuses.", @@ -60,6 +60,115 @@ ], "time": "2016-10-19T09:02:03+00:00" }, + { + "name": "matthiasmullie/minify", + "version": "1.3.63", + "source": { + "type": "git", + "url": "https://github.com/matthiasmullie/minify.git", + "reference": "9ba1b459828adc13430f4dd6c49dae4950dc4117" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/matthiasmullie/minify/zipball/9ba1b459828adc13430f4dd6c49dae4950dc4117", + "reference": "9ba1b459828adc13430f4dd6c49dae4950dc4117", + "shasum": "" + }, + "require": { + "ext-pcre": "*", + "matthiasmullie/path-converter": "~1.1", + "php": ">=5.3.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "~2.0", + "matthiasmullie/scrapbook": "~1.0", + "phpunit/phpunit": "~4.8" + }, + "suggest": { + "psr/cache-implementation": "Cache implementation to use with Minify::cache" + }, + "bin": [ + "bin/minifycss", + "bin/minifyjs" + ], + "type": "library", + "autoload": { + "psr-4": { + "MatthiasMullie\\Minify\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Matthias Mullie", + "email": "minify@mullie.eu", + "homepage": "http://www.mullie.eu", + "role": "Developer" + } + ], + "description": "CSS & JavaScript minifier, in PHP. Removes whitespace, strips comments, combines files (incl. @import statements and small assets in CSS files), and optimizes/shortens a few common programming patterns.", + "homepage": "http://www.minifier.org", + "keywords": [ + "JS", + "css", + "javascript", + "minifier", + "minify" + ], + "time": "2020-01-21T20:21:08+00:00" + }, + { + "name": "matthiasmullie/path-converter", + "version": "1.1.3", + "source": { + "type": "git", + "url": "https://github.com/matthiasmullie/path-converter.git", + "reference": "e7d13b2c7e2f2268e1424aaed02085518afa02d9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/matthiasmullie/path-converter/zipball/e7d13b2c7e2f2268e1424aaed02085518afa02d9", + "reference": "e7d13b2c7e2f2268e1424aaed02085518afa02d9", + "shasum": "" + }, + "require": { + "ext-pcre": "*", + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.8" + }, + "type": "library", + "autoload": { + "psr-4": { + "MatthiasMullie\\PathConverter\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Matthias Mullie", + "email": "pathconverter@mullie.eu", + "homepage": "http://www.mullie.eu", + "role": "Developer" + } + ], + "description": "Relative path converter", + "homepage": "http://github.com/matthiasmullie/path-converter", + "keywords": [ + "converter", + "path", + "paths", + "relative" + ], + "time": "2019-02-05T23:41:09+00:00" + }, { "name": "michelf/php-markdown", "version": "1.9.0", @@ -207,6 +316,322 @@ ], "time": "2018-06-10T16:08:54+00:00" }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.18.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "1c302646f6efc070cd46856e600e5e0684d6b454" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/1c302646f6efc070cd46856e600e5e0684d6b454", + "reference": "1c302646f6efc070cd46856e600e5e0684d6b454", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.18-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-07-14T12:35:20+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.18.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "a6977d63bf9a0ad4c65cd352709e230876f9904a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/a6977d63bf9a0ad4c65cd352709e230876f9904a", + "reference": "a6977d63bf9a0ad4c65cd352709e230876f9904a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.18-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-07-14T12:35:20+00:00" + }, + { + "name": "twig/markdown-extra", + "version": "v3.0.4", + "source": { + "type": "git", + "url": "https://github.com/twigphp/markdown-extra.git", + "reference": "32db423d2d359bd46591a3a8ac0cdc5935a394fc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/twigphp/markdown-extra/zipball/32db423d2d359bd46591a3a8ac0cdc5935a394fc", + "reference": "32db423d2d359bd46591a3a8ac0cdc5935a394fc", + "shasum": "" + }, + "require": { + "php": ">=7.1.3", + "twig/twig": "^2.4|^3.0" + }, + "require-dev": { + "erusev/parsedown": "^1.7", + "league/commonmark": "^1.0", + "league/html-to-markdown": "^4.8", + "michelf/php-markdown": "^1.8", + "symfony/phpunit-bridge": "^4.4.9|^5.0.9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "Twig\\Extra\\Markdown\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + } + ], + "description": "A Twig extension for Markdown", + "homepage": "https://twig.symfony.com", + "keywords": [ + "html", + "markdown", + "twig" + ], + "funding": [ + { + "url": "https://certification.symfony.com/", + "type": "custom" + }, + { + "url": "https://live.symfony.com/", + "type": "custom" + }, + { + "url": "https://symfony.com/cloud/", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/twig/twig", + "type": "tidelift" + } + ], + "time": "2020-05-21T09:56:39+00:00" + }, + { + "name": "twig/twig", + "version": "v3.0.4", + "source": { + "type": "git", + "url": "https://github.com/twigphp/Twig.git", + "reference": "582bdbdc173027ebfba3c93dc750a40b8f9ebc02" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/582bdbdc173027ebfba3c93dc750a40b8f9ebc02", + "reference": "582bdbdc173027ebfba3c93dc750a40b8f9ebc02", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-ctype": "^1.8", + "symfony/polyfill-mbstring": "^1.3" + }, + "require-dev": { + "psr/container": "^1.0", + "symfony/phpunit-bridge": "^4.4.9|^5.0.9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "Twig\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Twig Team", + "role": "Contributors" + }, + { + "name": "Armin Ronacher", + "email": "armin.ronacher@active-4.com", + "role": "Project Founder" + } + ], + "description": "Twig, the flexible, fast, and secure template language for PHP", + "homepage": "https://twig.symfony.com", + "keywords": [ + "templating" + ], + "funding": [ + { + "url": "https://certification.symfony.com/", + "type": "custom" + }, + { + "url": "https://live.symfony.com/", + "type": "custom" + }, + { + "url": "https://symfony.com/cloud/", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/twig/twig", + "type": "tidelift" + } + ], + "time": "2020-07-05T13:18:14+00:00" + }, { "name": "vanilla/garden-cli", "version": "v2.2", @@ -366,20 +791,20 @@ }, { "name": "myclabs/deep-copy", - "version": "1.9.5", + "version": "1.10.1", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "b2c28789e80a97badd14145fda39b545d83ca3ef" + "reference": "969b211f9a51aa1f6c01d1d2aef56d3bd91598e5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/b2c28789e80a97badd14145fda39b545d83ca3ef", - "reference": "b2c28789e80a97badd14145fda39b545d83ca3ef", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/969b211f9a51aa1f6c01d1d2aef56d3bd91598e5", + "reference": "969b211f9a51aa1f6c01d1d2aef56d3bd91598e5", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^7.1 || ^8.0" }, "replace": { "myclabs/deep-copy": "self.version" @@ -410,7 +835,13 @@ "object", "object graph" ], - "time": "2020-01-17T21:11:47+00:00" + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", + "type": "tidelift" + } + ], + "time": "2020-06-29T13:22:24+00:00" }, { "name": "phar-io/manifest", @@ -609,25 +1040,25 @@ }, { "name": "phpdocumentor/reflection-common", - "version": "2.1.0", + "version": "2.2.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "6568f4687e5b41b054365f9ae03fcb1ed5f2069b" + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/6568f4687e5b41b054365f9ae03fcb1ed5f2069b", - "reference": "6568f4687e5b41b054365f9ae03fcb1ed5f2069b", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", "shasum": "" }, "require": { - "php": ">=7.1" + "php": "^7.2 || ^8.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.x-dev" + "dev-2.x": "2.x-dev" } }, "autoload": { @@ -654,32 +1085,31 @@ "reflection", "static analysis" ], - "time": "2020-04-27T09:25:28+00:00" + "time": "2020-06-27T09:03:43+00:00" }, { "name": "phpdocumentor/reflection-docblock", - "version": "5.1.0", + "version": "5.2.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e" + "reference": "3170448f5769fe19f456173d833734e0ff1b84df" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e", - "reference": "cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/3170448f5769fe19f456173d833734e0ff1b84df", + "reference": "3170448f5769fe19f456173d833734e0ff1b84df", "shasum": "" }, "require": { - "ext-filter": "^7.1", - "php": "^7.2", - "phpdocumentor/reflection-common": "^2.0", - "phpdocumentor/type-resolver": "^1.0", - "webmozart/assert": "^1" + "ext-filter": "*", + "php": "^7.2 || ^8.0", + "phpdocumentor/reflection-common": "^2.2", + "phpdocumentor/type-resolver": "^1.3", + "webmozart/assert": "^1.9.1" }, "require-dev": { - "doctrine/instantiator": "^1", - "mockery/mockery": "^1" + "mockery/mockery": "~1.3.2" }, "type": "library", "extra": { @@ -707,29 +1137,28 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2020-02-22T12:28:44+00:00" + "time": "2020-07-20T20:05:34+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "1.2.0", + "version": "1.3.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "30441f2752e493c639526b215ed81d54f369d693" + "reference": "e878a14a65245fbe78f8080eba03b47c3b705651" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/30441f2752e493c639526b215ed81d54f369d693", - "reference": "30441f2752e493c639526b215ed81d54f369d693", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/e878a14a65245fbe78f8080eba03b47c3b705651", + "reference": "e878a14a65245fbe78f8080eba03b47c3b705651", "shasum": "" }, "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "phpdocumentor/reflection-common": "^2.0" }, "require-dev": { - "ext-tokenizer": "^7.2", - "mockery/mockery": "~1" + "ext-tokenizer": "*" }, "type": "library", "extra": { @@ -753,37 +1182,37 @@ } ], "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", - "time": "2020-06-19T20:22:09+00:00" + "time": "2020-06-27T10:12:23+00:00" }, { "name": "phpspec/prophecy", - "version": "v1.10.3", + "version": "1.11.1", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "451c3cd1418cf640de218914901e51b064abb093" + "reference": "b20034be5efcdab4fb60ca3a29cba2949aead160" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/451c3cd1418cf640de218914901e51b064abb093", - "reference": "451c3cd1418cf640de218914901e51b064abb093", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/b20034be5efcdab4fb60ca3a29cba2949aead160", + "reference": "b20034be5efcdab4fb60ca3a29cba2949aead160", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.0.2", - "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0", - "sebastian/comparator": "^1.2.3|^2.0|^3.0|^4.0", - "sebastian/recursion-context": "^1.0|^2.0|^3.0|^4.0" + "doctrine/instantiator": "^1.2", + "php": "^7.2", + "phpdocumentor/reflection-docblock": "^5.0", + "sebastian/comparator": "^3.0 || ^4.0", + "sebastian/recursion-context": "^3.0 || ^4.0" }, "require-dev": { - "phpspec/phpspec": "^2.5 || ^3.2", - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" + "phpspec/phpspec": "^6.0", + "phpunit/phpunit": "^8.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.10.x-dev" + "dev-master": "1.11.x-dev" } }, "autoload": { @@ -816,7 +1245,7 @@ "spy", "stub" ], - "time": "2020-03-05T15:02:03+00:00" + "time": "2020-07-08T12:44:21+00:00" }, { "name": "phpstan/phpstan", @@ -932,40 +1361,41 @@ }, { "name": "phpunit/php-code-coverage", - "version": "7.0.10", + "version": "8.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "f1884187926fbb755a9aaf0b3836ad3165b478bf" + "reference": "ca6647ffddd2add025ab3f21644a441d7c146cdc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f1884187926fbb755a9aaf0b3836ad3165b478bf", - "reference": "f1884187926fbb755a9aaf0b3836ad3165b478bf", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ca6647ffddd2add025ab3f21644a441d7c146cdc", + "reference": "ca6647ffddd2add025ab3f21644a441d7c146cdc", "shasum": "" }, "require": { "ext-dom": "*", "ext-xmlwriter": "*", - "php": "^7.2", - "phpunit/php-file-iterator": "^2.0.2", - "phpunit/php-text-template": "^1.2.1", - "phpunit/php-token-stream": "^3.1.1", - "sebastian/code-unit-reverse-lookup": "^1.0.1", - "sebastian/environment": "^4.2.2", - "sebastian/version": "^2.0.1", + "php": "^7.3", + "phpunit/php-file-iterator": "^3.0", + "phpunit/php-text-template": "^2.0", + "phpunit/php-token-stream": "^4.0", + "sebastian/code-unit-reverse-lookup": "^2.0", + "sebastian/environment": "^5.0", + "sebastian/version": "^3.0", "theseer/tokenizer": "^1.1.3" }, "require-dev": { - "phpunit/phpunit": "^8.2.2" + "phpunit/phpunit": "^9.0" }, "suggest": { - "ext-xdebug": "^2.7.2" + "ext-pcov": "*", + "ext-xdebug": "*" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "7.0-dev" + "dev-master": "8.0-dev" } }, "autoload": { @@ -991,32 +1421,38 @@ "testing", "xunit" ], - "time": "2019-11-20T13:55:58+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-05-23T08:02:54+00:00" }, { "name": "phpunit/php-file-iterator", - "version": "2.0.2", + "version": "3.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "050bedf145a257b1ff02746c31894800e5122946" + "reference": "25fefc5b19835ca653877fe081644a3f8c1d915e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/050bedf145a257b1ff02746c31894800e5122946", - "reference": "050bedf145a257b1ff02746c31894800e5122946", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/25fefc5b19835ca653877fe081644a3f8c1d915e", + "reference": "25fefc5b19835ca653877fe081644a3f8c1d915e", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^7.3 || ^8.0" }, "require-dev": { - "phpunit/phpunit": "^7.1" + "phpunit/phpunit": "^9.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -1041,26 +1477,99 @@ "filesystem", "iterator" ], - "time": "2018-09-13T20:33:42+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-07-11T05:18:21+00:00" + }, + { + "name": "phpunit/php-invoker", + "version": "3.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-invoker.git", + "reference": "f6eedfed1085dd1f4c599629459a0277d25f9a66" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/f6eedfed1085dd1f4c599629459a0277d25f9a66", + "reference": "f6eedfed1085dd1f4c599629459a0277d25f9a66", + "shasum": "" + }, + "require": { + "php": "^7.3 || ^8.0" + }, + "require-dev": { + "ext-pcntl": "*", + "phpunit/phpunit": "^9.0" + }, + "suggest": { + "ext-pcntl": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Invoke callables with a timeout", + "homepage": "https://github.com/sebastianbergmann/php-invoker/", + "keywords": [ + "process" + ], + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-26T11:53:53+00:00" }, { "name": "phpunit/php-text-template", - "version": "1.2.1", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" + "reference": "6ff9c8ea4d3212b88fcf74e25e516e2c51c99324" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/6ff9c8ea4d3212b88fcf74e25e516e2c51c99324", + "reference": "6ff9c8ea4d3212b88fcf74e25e516e2c51c99324", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^7.3 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, "autoload": { "classmap": [ "src/" @@ -1082,32 +1591,38 @@ "keywords": [ "template" ], - "time": "2015-06-21T13:50:34+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-26T11:55:37+00:00" }, { "name": "phpunit/php-timer", - "version": "2.1.2", + "version": "5.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "1038454804406b0b5f5f520358e78c1c2f71501e" + "reference": "cc49734779cbb302bf51a44297dab8c4bbf941e7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/1038454804406b0b5f5f520358e78c1c2f71501e", - "reference": "1038454804406b0b5f5f520358e78c1c2f71501e", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/cc49734779cbb302bf51a44297dab8c4bbf941e7", + "reference": "cc49734779cbb302bf51a44297dab8c4bbf941e7", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^7.3 || ^8.0" }, "require-dev": { - "phpunit/phpunit": "^7.0" + "phpunit/phpunit": "^9.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -1131,33 +1646,39 @@ "keywords": [ "timer" ], - "time": "2019-06-07T04:22:29+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-26T11:58:13+00:00" }, { "name": "phpunit/php-token-stream", - "version": "3.1.1", + "version": "4.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "995192df77f63a59e47f025390d2d1fdf8f425ff" + "reference": "5672711b6b07b14d5ab694e700c62eeb82fcf374" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/995192df77f63a59e47f025390d2d1fdf8f425ff", - "reference": "995192df77f63a59e47f025390d2d1fdf8f425ff", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/5672711b6b07b14d5ab694e700c62eeb82fcf374", + "reference": "5672711b6b07b14d5ab694e700c62eeb82fcf374", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": "^7.1" + "php": "^7.3 || ^8.0" }, "require-dev": { - "phpunit/phpunit": "^7.0" + "phpunit/phpunit": "^9.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.1-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -1180,56 +1701,64 @@ "keywords": [ "tokenizer" ], - "time": "2019-09-17T06:23:10+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-27T06:36:25+00:00" }, { "name": "phpunit/phpunit", - "version": "8.5.8", + "version": "9.2.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "34c18baa6a44f1d1fbf0338907139e9dce95b997" + "reference": "1c6a9e4312e209e659f1fce3ce88dd197c2448f6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/34c18baa6a44f1d1fbf0338907139e9dce95b997", - "reference": "34c18baa6a44f1d1fbf0338907139e9dce95b997", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/1c6a9e4312e209e659f1fce3ce88dd197c2448f6", + "reference": "1c6a9e4312e209e659f1fce3ce88dd197c2448f6", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.2.0", + "doctrine/instantiator": "^1.3.1", "ext-dom": "*", "ext-json": "*", "ext-libxml": "*", "ext-mbstring": "*", "ext-xml": "*", "ext-xmlwriter": "*", - "myclabs/deep-copy": "^1.9.1", + "myclabs/deep-copy": "^1.9.5", "phar-io/manifest": "^1.0.3", "phar-io/version": "^2.0.1", - "php": "^7.2", - "phpspec/prophecy": "^1.8.1", - "phpunit/php-code-coverage": "^7.0.7", - "phpunit/php-file-iterator": "^2.0.2", - "phpunit/php-text-template": "^1.2.1", - "phpunit/php-timer": "^2.1.2", - "sebastian/comparator": "^3.0.2", - "sebastian/diff": "^3.0.2", - "sebastian/environment": "^4.2.2", - "sebastian/exporter": "^3.1.1", - "sebastian/global-state": "^3.0.0", - "sebastian/object-enumerator": "^3.0.3", - "sebastian/resource-operations": "^2.0.1", - "sebastian/type": "^1.1.3", - "sebastian/version": "^2.0.1" + "php": "^7.3", + "phpspec/prophecy": "^1.10.3", + "phpunit/php-code-coverage": "^8.0.2", + "phpunit/php-file-iterator": "^3.0.3", + "phpunit/php-invoker": "^3.0.2", + "phpunit/php-text-template": "^2.0.2", + "phpunit/php-timer": "^5.0.1", + "sebastian/code-unit": "^1.0.5", + "sebastian/comparator": "^4.0.3", + "sebastian/diff": "^4.0.1", + "sebastian/environment": "^5.1.2", + "sebastian/exporter": "^4.0.2", + "sebastian/global-state": "^4.0", + "sebastian/object-enumerator": "^4.0.2", + "sebastian/resource-operations": "^3.0.2", + "sebastian/type": "^2.1.1", + "sebastian/version": "^3.0.1" }, "require-dev": { - "ext-pdo": "*" + "ext-pdo": "*", + "phpspec/prophecy-phpunit": "^2.0" }, "suggest": { "ext-soap": "*", - "ext-xdebug": "*", - "phpunit/php-invoker": "^2.0.0" + "ext-xdebug": "*" }, "bin": [ "phpunit" @@ -1237,12 +1766,15 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "8.5-dev" + "dev-master": "9.2-dev" } }, "autoload": { "classmap": [ "src/" + ], + "files": [ + "src/Framework/Assert/Functions.php" ] }, "notification-url": "https://packagist.org/downloads/", @@ -1273,32 +1805,84 @@ "type": "github" } ], - "time": "2020-06-22T07:06:58+00:00" + "time": "2020-07-13T17:55:55+00:00" + }, + { + "name": "sebastian/code-unit", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit.git", + "reference": "c1e2df332c905079980b119c4db103117e5e5c90" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/c1e2df332c905079980b119c4db103117e5e5c90", + "reference": "c1e2df332c905079980b119c4db103117e5e5c90", + "shasum": "" + }, + "require": { + "php": "^7.3 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the PHP code units", + "homepage": "https://github.com/sebastianbergmann/code-unit", + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-26T12:50:45+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", - "version": "1.0.1", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18" + "reference": "ee51f9bb0c6d8a43337055db3120829fa14da819" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", - "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/ee51f9bb0c6d8a43337055db3120829fa14da819", + "reference": "ee51f9bb0c6d8a43337055db3120829fa14da819", "shasum": "" }, "require": { - "php": "^5.6 || ^7.0" + "php": "^7.3 || ^8.0" }, "require-dev": { - "phpunit/phpunit": "^5.7 || ^6.0" + "phpunit/phpunit": "^9.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -1318,34 +1902,40 @@ ], "description": "Looks up which function or method a line of code belongs to", "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", - "time": "2017-03-04T06:30:41+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-26T12:04:00+00:00" }, { "name": "sebastian/comparator", - "version": "3.0.2", + "version": "4.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da" + "reference": "dcc580eadfaa4e7f9d2cf9ae1922134ea962e14f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/5de4fc177adf9bce8df98d8d141a7559d7ccf6da", - "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/dcc580eadfaa4e7f9d2cf9ae1922134ea962e14f", + "reference": "dcc580eadfaa4e7f9d2cf9ae1922134ea962e14f", "shasum": "" }, "require": { - "php": "^7.1", - "sebastian/diff": "^3.0", - "sebastian/exporter": "^3.1" + "php": "^7.3 || ^8.0", + "sebastian/diff": "^4.0", + "sebastian/exporter": "^4.0" }, "require-dev": { - "phpunit/phpunit": "^7.1" + "phpunit/phpunit": "^9.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -1358,6 +1948,10 @@ "BSD-3-Clause" ], "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, { "name": "Jeff Welch", "email": "whatthejeff@gmail.com" @@ -1369,10 +1963,6 @@ { "name": "Bernhard Schussek", "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" } ], "description": "Provides the functionality to compare PHP values for equality", @@ -1382,33 +1972,39 @@ "compare", "equality" ], - "time": "2018-07-12T15:12:46+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-26T12:05:46+00:00" }, { "name": "sebastian/diff", - "version": "3.0.2", + "version": "4.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29" + "reference": "1e90b4cf905a7d06c420b1d2e9d11a4dc8a13113" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/720fcc7e9b5cf384ea68d9d930d480907a0c1a29", - "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/1e90b4cf905a7d06c420b1d2e9d11a4dc8a13113", + "reference": "1e90b4cf905a7d06c420b1d2e9d11a4dc8a13113", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^7.3 || ^8.0" }, "require-dev": { - "phpunit/phpunit": "^7.5 || ^8.0", - "symfony/process": "^2 || ^3.3 || ^4" + "phpunit/phpunit": "^9.0", + "symfony/process": "^4.2 || ^5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -1421,13 +2017,13 @@ "BSD-3-Clause" ], "authors": [ - { - "name": "Kore Nordmann", - "email": "mail@kore-nordmann.de" - }, { "name": "Sebastian Bergmann", "email": "sebastian@phpunit.de" + }, + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" } ], "description": "Diff implementation", @@ -1438,27 +2034,33 @@ "unidiff", "unified diff" ], - "time": "2019-02-04T06:01:07+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-30T04:46:02+00:00" }, { "name": "sebastian/environment", - "version": "4.2.3", + "version": "5.1.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "464c90d7bdf5ad4e8a6aea15c091fec0603d4368" + "reference": "0a757cab9d5b7ef49a619f1143e6c9c1bc0fe9d2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/464c90d7bdf5ad4e8a6aea15c091fec0603d4368", - "reference": "464c90d7bdf5ad4e8a6aea15c091fec0603d4368", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/0a757cab9d5b7ef49a619f1143e6c9c1bc0fe9d2", + "reference": "0a757cab9d5b7ef49a619f1143e6c9c1bc0fe9d2", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^7.3 || ^8.0" }, "require-dev": { - "phpunit/phpunit": "^7.5" + "phpunit/phpunit": "^9.0" }, "suggest": { "ext-posix": "*" @@ -1466,7 +2068,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.2-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -1491,34 +2093,40 @@ "environment", "hhvm" ], - "time": "2019-11-20T08:46:58+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-26T12:07:24+00:00" }, { "name": "sebastian/exporter", - "version": "3.1.2", + "version": "4.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e" + "reference": "571d721db4aec847a0e59690b954af33ebf9f023" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/68609e1261d215ea5b21b7987539cbfbe156ec3e", - "reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/571d721db4aec847a0e59690b954af33ebf9f023", + "reference": "571d721db4aec847a0e59690b954af33ebf9f023", "shasum": "" }, "require": { - "php": "^7.0", - "sebastian/recursion-context": "^3.0" + "php": "^7.3 || ^8.0", + "sebastian/recursion-context": "^4.0" }, "require-dev": { "ext-mbstring": "*", - "phpunit/phpunit": "^6.0" + "phpunit/phpunit": "^9.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.1.x-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -1558,30 +2166,36 @@ "export", "exporter" ], - "time": "2019-09-14T09:02:43+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-26T12:08:55+00:00" }, { "name": "sebastian/global-state", - "version": "3.0.0", + "version": "4.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "edf8a461cf1d4005f19fb0b6b8b95a9f7fa0adc4" + "reference": "bdb1e7c79e592b8c82cb1699be3c8743119b8a72" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/edf8a461cf1d4005f19fb0b6b8b95a9f7fa0adc4", - "reference": "edf8a461cf1d4005f19fb0b6b8b95a9f7fa0adc4", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bdb1e7c79e592b8c82cb1699be3c8743119b8a72", + "reference": "bdb1e7c79e592b8c82cb1699be3c8743119b8a72", "shasum": "" }, "require": { - "php": "^7.2", - "sebastian/object-reflector": "^1.1.1", - "sebastian/recursion-context": "^3.0" + "php": "^7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" }, "require-dev": { "ext-dom": "*", - "phpunit/phpunit": "^8.0" + "phpunit/phpunit": "^9.0" }, "suggest": { "ext-uopz": "*" @@ -1589,7 +2203,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -1612,34 +2226,34 @@ "keywords": [ "global state" ], - "time": "2019-02-01T05:30:01+00:00" + "time": "2020-02-07T06:11:37+00:00" }, { "name": "sebastian/object-enumerator", - "version": "3.0.3", + "version": "4.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5" + "reference": "074fed2d0a6d08e1677dd8ce9d32aecb384917b8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/7cfd9e65d11ffb5af41198476395774d4c8a84c5", - "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/074fed2d0a6d08e1677dd8ce9d32aecb384917b8", + "reference": "074fed2d0a6d08e1677dd8ce9d32aecb384917b8", "shasum": "" }, "require": { - "php": "^7.0", - "sebastian/object-reflector": "^1.1.1", - "sebastian/recursion-context": "^3.0" + "php": "^7.3 || ^8.0", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" }, "require-dev": { - "phpunit/phpunit": "^6.0" + "phpunit/phpunit": "^9.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0.x-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -1659,32 +2273,38 @@ ], "description": "Traverses array structures and object graphs to enumerate all referenced objects", "homepage": "https://github.com/sebastianbergmann/object-enumerator/", - "time": "2017-08-03T12:35:26+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-26T12:11:32+00:00" }, { "name": "sebastian/object-reflector", - "version": "1.1.1", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-reflector.git", - "reference": "773f97c67f28de00d397be301821b06708fca0be" + "reference": "127a46f6b057441b201253526f81d5406d6c7840" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/773f97c67f28de00d397be301821b06708fca0be", - "reference": "773f97c67f28de00d397be301821b06708fca0be", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/127a46f6b057441b201253526f81d5406d6c7840", + "reference": "127a46f6b057441b201253526f81d5406d6c7840", "shasum": "" }, "require": { - "php": "^7.0" + "php": "^7.3 || ^8.0" }, "require-dev": { - "phpunit/phpunit": "^6.0" + "phpunit/phpunit": "^9.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -1704,32 +2324,38 @@ ], "description": "Allows reflection of object attributes, including inherited and non-public ones", "homepage": "https://github.com/sebastianbergmann/object-reflector/", - "time": "2017-03-29T09:07:27+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-26T12:12:55+00:00" }, { "name": "sebastian/recursion-context", - "version": "3.0.0", + "version": "4.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8" + "reference": "062231bf61d2b9448c4fa5a7643b5e1829c11d63" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", - "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/062231bf61d2b9448c4fa5a7643b5e1829c11d63", + "reference": "062231bf61d2b9448c4fa5a7643b5e1829c11d63", "shasum": "" }, "require": { - "php": "^7.0" + "php": "^7.3 || ^8.0" }, "require-dev": { - "phpunit/phpunit": "^6.0" + "phpunit/phpunit": "^9.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0.x-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -1742,14 +2368,14 @@ "BSD-3-Clause" ], "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, { "name": "Sebastian Bergmann", "email": "sebastian@phpunit.de" }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, { "name": "Adam Harvey", "email": "aharvey@php.net" @@ -1757,29 +2383,38 @@ ], "description": "Provides functionality to recursively process PHP variables", "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2017-03-03T06:23:57+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-26T12:14:17+00:00" }, { "name": "sebastian/resource-operations", - "version": "2.0.1", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9" + "reference": "0653718a5a629b065e91f774595267f8dc32e213" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/4d7a795d35b889bf80a0cc04e08d77cedfa917a9", - "reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/0653718a5a629b065e91f774595267f8dc32e213", + "reference": "0653718a5a629b065e91f774595267f8dc32e213", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^7.3 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -1799,32 +2434,38 @@ ], "description": "Provides a list of PHP built-in functions that operate on resources", "homepage": "https://www.github.com/sebastianbergmann/resource-operations", - "time": "2018-10-04T04:07:39+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-26T12:16:22+00:00" }, { "name": "sebastian/type", - "version": "1.1.3", + "version": "2.2.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "3aaaa15fa71d27650d62a948be022fe3b48541a3" + "reference": "86991e2b33446cd96e648c18bcdb1e95afb2c05a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/3aaaa15fa71d27650d62a948be022fe3b48541a3", - "reference": "3aaaa15fa71d27650d62a948be022fe3b48541a3", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/86991e2b33446cd96e648c18bcdb1e95afb2c05a", + "reference": "86991e2b33446cd96e648c18bcdb1e95afb2c05a", "shasum": "" }, "require": { - "php": "^7.2" + "php": "^7.3 || ^8.0" }, "require-dev": { - "phpunit/phpunit": "^8.2" + "phpunit/phpunit": "^9.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1-dev" + "dev-master": "2.2-dev" } }, "autoload": { @@ -1845,29 +2486,35 @@ ], "description": "Collection of value objects that represent the types of the PHP type system", "homepage": "https://github.com/sebastianbergmann/type", - "time": "2019-07-02T08:10:15+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-07-05T08:31:53+00:00" }, { "name": "sebastian/version", - "version": "2.0.1", + "version": "3.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/version.git", - "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019" + "reference": "626586115d0ed31cb71483be55beb759b5af5a3c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019", - "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/626586115d0ed31cb71483be55beb759b5af5a3c", + "reference": "626586115d0ed31cb71483be55beb759b5af5a3c", "shasum": "" }, "require": { - "php": ">=5.6" + "php": "^7.3 || ^8.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -1888,83 +2535,13 @@ ], "description": "Library that helps with managing the version number of Git-hosted PHP projects", "homepage": "https://github.com/sebastianbergmann/version", - "time": "2016-10-03T07:35:21+00:00" - }, - { - "name": "symfony/polyfill-ctype", - "version": "v1.17.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "2edd75b8b35d62fd3eeabba73b26b8f1f60ce13d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/2edd75b8b35d62fd3eeabba73b26b8f1f60ce13d", - "reference": "2edd75b8b35d62fd3eeabba73b26b8f1f60ce13d", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "suggest": { - "ext-ctype": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.17-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Gert de Pagter", - "email": "BackEndTea@gmail.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for ctype functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "ctype", - "polyfill", - "portable" - ], "funding": [ { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", + "url": "https://github.com/sebastianbergmann", "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" } ], - "time": "2020-06-06T08:46:27+00:00" + "time": "2020-06-26T12:18:43+00:00" }, { "name": "theseer/autoload", @@ -2059,23 +2636,23 @@ }, { "name": "theseer/tokenizer", - "version": "1.1.3", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/theseer/tokenizer.git", - "reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9" + "reference": "75a63c33a8577608444246075ea0af0d052e452a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/11336f6f84e16a720dae9d8e6ed5019efa85a0f9", - "reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/75a63c33a8577608444246075ea0af0d052e452a", + "reference": "75a63c33a8577608444246075ea0af0d052e452a", "shasum": "" }, "require": { "ext-dom": "*", "ext-tokenizer": "*", "ext-xmlwriter": "*", - "php": "^7.0" + "php": "^7.2 || ^8.0" }, "type": "library", "autoload": { @@ -2095,24 +2672,30 @@ } ], "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", - "time": "2019-06-13T22:48:21+00:00" + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2020-07-12T23:59:07+00:00" }, { "name": "webmozart/assert", - "version": "1.9.0", + "version": "1.9.1", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "9dc4f203e36f2b486149058bade43c851dd97451" + "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/9dc4f203e36f2b486149058bade43c851dd97451", - "reference": "9dc4f203e36f2b486149058bade43c851dd97451", + "url": "https://api.github.com/repos/webmozart/assert/zipball/bafc69caeb4d49c39fd0779086c03a3738cbb389", + "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0", + "php": "^5.3.3 || ^7.0 || ^8.0", "symfony/polyfill-ctype": "^1.8" }, "conflict": { @@ -2144,7 +2727,7 @@ "check", "validate" ], - "time": "2020-06-16T10:16:42+00:00" + "time": "2020-07-08T17:02:28+00:00" }, { "name": "zetacomponents/base", diff --git a/phpdraft b/phpdraft index 3268b78a..7e2f48c0 100755 --- a/phpdraft +++ b/phpdraft @@ -77,11 +77,14 @@ try $color1 = getenv('COLOR_PRIMARY') === FALSE ? NULL : getenv('COLOR_PRIMARY'); $color2 = getenv('COLOR_SECONDARY') === FALSE ? NULL : getenv('COLOR_SECONDARY'); $colors = (is_null($color1) || is_null($color2)) ? '' : '__' . $color1 . '__' . $color2; - $generator = $html->get_html( - $args->getOpt('template', 'default') . $colors, - $args['header_image'], - $args['css'], - $args['javascript']); + $html->build_html( + $args->getOpt('template', 'default') . $colors, + $args['header_image'], + $args['css'], + $args['javascript'] + ); + + echo $html; } catch (ExecutionException $exception) { diff --git a/src/PHPDraft/Model/Elements/BasicStructureElement.php b/src/PHPDraft/Model/Elements/BasicStructureElement.php index b1ece42e..3be386a7 100644 --- a/src/PHPDraft/Model/Elements/BasicStructureElement.php +++ b/src/PHPDraft/Model/Elements/BasicStructureElement.php @@ -8,8 +8,6 @@ namespace PHPDraft\Model\Elements; -use Michelf\MarkdownExtra; - abstract class BasicStructureElement implements StructureElement { /** @@ -120,7 +118,7 @@ protected function parse_common(object $object, array &$dependencies): void } if ($this->description !== null) { $encoded = htmlentities($this->description, ENT_COMPAT, null, false); - $this->description = MarkdownExtra::defaultTransform($encoded); + $this->description = $encoded; } $this->ref = null; diff --git a/src/PHPDraft/Model/Elements/ObjectStructureElement.php b/src/PHPDraft/Model/Elements/ObjectStructureElement.php index 485c2478..985eb5f1 100644 --- a/src/PHPDraft/Model/Elements/ObjectStructureElement.php +++ b/src/PHPDraft/Model/Elements/ObjectStructureElement.php @@ -152,10 +152,6 @@ public function __toString(): string return "$return
"; } - if ($this->ref !== null) { - return '

Inherits from ' . $this->ref . '

'; - } - if ($this->value === null && $this->key === null && $this->description !== null) { return ''; } @@ -209,7 +205,8 @@ protected function construct_string_return(string $value): string $variable = ''; if ($this->is_variable) { $link_name = str_replace(' ', '-', strtolower($this->key->type)); - $variable = ''; + $tooltip = 'This is a variable key of type "' . $this->key->type . '"'; + $variable = ''; } return '' . diff --git a/src/PHPDraft/Model/Elements/Tests/ArrayStructureElementTest.php b/src/PHPDraft/Model/Elements/Tests/ArrayStructureElementTest.php index f04a4e92..f51df81e 100644 --- a/src/PHPDraft/Model/Elements/Tests/ArrayStructureElementTest.php +++ b/src/PHPDraft/Model/Elements/Tests/ArrayStructureElementTest.php @@ -104,7 +104,7 @@ public function parseObjectProvider(): array $base3->element = 'member'; $base3->type = 'array'; $base3->is_variable = false; - $base3->description = "

List of car identifiers to retrieve

\n"; + $base3->description = "List of car identifiers to retrieve"; $base3->deps = []; $return['generic value type'] = [ diff --git a/src/PHPDraft/Model/Elements/Tests/BasicStructureElementTest.php b/src/PHPDraft/Model/Elements/Tests/BasicStructureElementTest.php index f77183b3..910b7db9 100644 --- a/src/PHPDraft/Model/Elements/Tests/BasicStructureElementTest.php +++ b/src/PHPDraft/Model/Elements/Tests/BasicStructureElementTest.php @@ -157,7 +157,7 @@ public function parseValueProvider(): array $obj3 = clone $obj; $obj3->meta->description = '__hello__'; - $answer->description = '

hello

' . PHP_EOL; + $answer->description = '__hello__'; $return[] = [$obj3, $answer]; diff --git a/src/PHPDraft/Model/Elements/Tests/EnumStructureElementTest.php b/src/PHPDraft/Model/Elements/Tests/EnumStructureElementTest.php index 834a12db..8029c60e 100644 --- a/src/PHPDraft/Model/Elements/Tests/EnumStructureElementTest.php +++ b/src/PHPDraft/Model/Elements/Tests/EnumStructureElementTest.php @@ -172,7 +172,7 @@ public function parseObjectProvider(): array $base3->status = 'optional'; $base3->element = 'member'; $base3->type = 'number'; - $base3->description = "

List of car identifiers to retrieve

\n"; + $base3->description = "List of car identifiers to retrieve"; $base3->is_variable = false; $base3->deps = []; diff --git a/src/PHPDraft/Model/Elements/Tests/ObjectStructureElementTest.php b/src/PHPDraft/Model/Elements/Tests/ObjectStructureElementTest.php index 6c6d5559..83ef3b18 100644 --- a/src/PHPDraft/Model/Elements/Tests/ObjectStructureElementTest.php +++ b/src/PHPDraft/Model/Elements/Tests/ObjectStructureElementTest.php @@ -86,7 +86,7 @@ public function parseObjectProvider(): array $base1->element = 'member'; $base1->type = 'string'; $base1->is_variable = false; - $base1->description = "

desc1

\n"; + $base1->description = "desc1"; $base2 = new ObjectStructureElement(); $base2->key = new ElementStructureElement(); @@ -97,7 +97,7 @@ public function parseObjectProvider(): array $base2->element = 'member'; $base2->type = 'string'; $base2->is_variable = false; - $base2->description = "

desc2

\n"; + $base2->description = "desc2"; $base3 = clone $base2; $base3->value = 'test1 (string) | test2 (int) | test3 (Cow)'; diff --git a/src/PHPDraft/Model/Elements/Tests/RequestBodyElementTest.php b/src/PHPDraft/Model/Elements/Tests/RequestBodyElementTest.php index 54e865b0..854f0e8e 100644 --- a/src/PHPDraft/Model/Elements/Tests/RequestBodyElementTest.php +++ b/src/PHPDraft/Model/Elements/Tests/RequestBodyElementTest.php @@ -140,7 +140,7 @@ public function parseObjectProvider(): array $base1->element = 'member'; $base1->type = 'string'; $base1->is_variable = false; - $base1->description = "

desc1

\n"; + $base1->description = "desc1"; $base2 = new RequestBodyElement(); $base2->key = new ElementStructureElement(); @@ -151,7 +151,7 @@ public function parseObjectProvider(): array $base2->element = 'member'; $base2->type = 'string'; $base2->is_variable = false; - $base2->description = "

desc2

\n"; + $base2->description = "desc2"; $base3 = clone $base2; $base3->value = 'test1 (string) | test2 (string) | test3 (string)'; diff --git a/src/PHPDraft/Model/HTTPRequest.php b/src/PHPDraft/Model/HTTPRequest.php index d8aec299..24d4e050 100644 --- a/src/PHPDraft/Model/HTTPRequest.php +++ b/src/PHPDraft/Model/HTTPRequest.php @@ -12,7 +12,6 @@ namespace PHPDraft\Model; -use Michelf\MarkdownExtra; use PHPDraft\Model\Elements\RequestBodyElement; use PHPDraft\Model\Elements\StructureElement; use QL\UriTemplate\Exception; @@ -112,7 +111,7 @@ public function parse(object $object): self } if ($value->element === 'copy') { - $this->description = MarkdownExtra::defaultTransform(htmlentities($value->content)); + $this->description = $value->content; continue; } @@ -226,6 +225,22 @@ public function get_curl_command(string $base_url, array $additional = []): stri */ public function is_equal_to($b): bool { - return ($this->method === $b->method) && ($this->body === $b->body) && ($this->headers === $b->headers); + if (!($b instanceof self)){ + return false; + } + return ($this->method === $b->method) + && ($this->body == $b->body) + && ($this->headers == $b->headers) + && ($this->title === $b->title); + } + + /** + * Convert class to string identifier + */ + public function __toString() + { + $headers = json_encode($this->headers); + $body = json_encode($this->body); + return "{$this->method}_{$body}_{$headers}"; } } diff --git a/src/PHPDraft/Model/HTTPResponse.php b/src/PHPDraft/Model/HTTPResponse.php index 974d3f2b..cd3d36d2 100644 --- a/src/PHPDraft/Model/HTTPResponse.php +++ b/src/PHPDraft/Model/HTTPResponse.php @@ -12,7 +12,6 @@ namespace PHPDraft\Model; -use Michelf\MarkdownExtra; use PHPDraft\Model\Elements\ObjectStructureElement; use stdClass; @@ -128,7 +127,7 @@ protected function parse_content(stdClass $object): void { foreach ($object->content as $value) { if ($value->element === 'copy') { - $this->description = MarkdownExtra::defaultTransform(htmlentities($value->content)); + $this->description = $value->content; continue; } @@ -174,6 +173,18 @@ protected function parse_structure(array $objects): void */ public function is_equal_to($b): bool { - return ($this->statuscode === $b->statuscode) && ($this->description === $b->description); + if (!($b instanceof self)){ + return false; + } + return ($this->statuscode === $b->statuscode) + && ($this->description === $b->description); + } + + /** + * Convert class to string identifier + */ + public function __toString() + { + return "{$this->statuscode}_{$this->description}"; } } diff --git a/src/PHPDraft/Model/HierarchyElement.php b/src/PHPDraft/Model/HierarchyElement.php index 082a49ca..6327ae81 100644 --- a/src/PHPDraft/Model/HierarchyElement.php +++ b/src/PHPDraft/Model/HierarchyElement.php @@ -12,7 +12,6 @@ namespace PHPDraft\Model; -use Michelf\MarkdownExtra; use stdClass; /** @@ -67,7 +66,7 @@ public function parse(stdClass $object) foreach ($object->content as $key => $item) { if ($item->element === 'copy') { - $this->description = preg_replace('/(<\/?p>)/', '', MarkdownExtra::defaultTransform(htmlentities($item->content)), 2); + $this->description = $item->content; unset($object->content[$key]); continue; } diff --git a/src/PHPDraft/Model/Tests/HTTPRequestTest.php b/src/PHPDraft/Model/Tests/HTTPRequestTest.php index 46448a80..f8116147 100644 --- a/src/PHPDraft/Model/Tests/HTTPRequestTest.php +++ b/src/PHPDraft/Model/Tests/HTTPRequestTest.php @@ -77,9 +77,7 @@ public function testGetId(): void */ public function testEqualOnStatusCode(): void { - $property = $this->reflection->getProperty('method'); - $property->setAccessible(true); - $property->setValue($this->class, 200); + $this->set_reflection_property_value('method', 'POST'); $obj = '{"method":200, "body":"hello", "headers":[]}'; @@ -93,9 +91,7 @@ public function testEqualOnStatusCode(): void */ public function testEqualOnDesc(): void { - $property = $this->reflection->getProperty('body'); - $property->setAccessible(true); - $property->setValue($this->class, 'hello'); + $this->set_reflection_property_value('body', 'hello'); $obj = '{"method":300, "body":"hello", "headers":[]}'; @@ -109,9 +105,7 @@ public function testEqualOnDesc(): void */ public function testEqualOnHeaders(): void { - $property = $this->reflection->getProperty('headers'); - $property->setAccessible(true); - $property->setValue($this->class, []); + $this->set_reflection_property_value('headers', []); $obj = '{"method":300, "body":"hello", "headers":[]}'; @@ -125,19 +119,14 @@ public function testEqualOnHeaders(): void */ public function testEqualOnBoth(): void { - $s_property = $this->reflection->getProperty('method'); - $s_property->setAccessible(true); - $s_property->setValue($this->class, 200); - - $property = $this->reflection->getProperty('body'); - $property->setAccessible(true); - $property->setValue($this->class, 'hello'); - - $obj = '{"method":200, "body":"hello", "headers":[]}'; + $this->set_reflection_property_value('method', 'GET'); + $this->set_reflection_property_value('title', 'hello'); - $return = $this->class->is_equal_to(json_decode($obj)); + $obj = '{"attributes":{"method": "GET"}, "meta":{"title":"hello"}}'; + $b = new HTTPRequest($this->parent); + $b->parse(json_decode($obj)); - $this->assertTrue($return); + $this->assertTrue($this->class->is_equal_to($b)); } /** @@ -145,9 +134,7 @@ public function testEqualOnBoth(): void */ public function testGetCurlCommandNoKey(): void { - $property = $this->reflection->getProperty('parent'); - $property->setAccessible(true); - $property->setValue($this->class, $this->parent); + $this->set_reflection_property_value('parent', $this->parent); $return = $this->class->get_curl_command('https://ur.l'); @@ -159,14 +146,10 @@ public function testGetCurlCommandNoKey(): void */ public function testGetCurlCommandWithHeaders(): void { - $property = $this->reflection->getProperty('parent'); - $property->setAccessible(true); - $property->setValue($this->class, $this->parent); + $this->set_reflection_property_value('parent', $this->parent); $headers = ['header' => 'value']; - $property = $this->reflection->getProperty('headers'); - $property->setAccessible(true); - $property->setValue($this->class, $headers); + $this->set_reflection_property_value('headers', $headers); $return = $this->class->get_curl_command('https://ur.l'); @@ -194,9 +177,7 @@ public function testGetCurlCommandArrayBody(): void { $this->set_reflection_property_value('parent', $this->parent); $this->set_reflection_property_value('method', 'GET'); - $property = $this->reflection->getProperty('body'); - $property->setAccessible(true); - $property->setValue($this->class, ['this', 'is', 'a', 'body']); + $this->set_reflection_property_value('body', ['this', 'is', 'a', 'body']); $return = $this->class->get_curl_command('https://ur.l'); @@ -210,9 +191,7 @@ public function testGetCurlCommandStructBodyFilled(): void { $this->set_reflection_property_value('parent', $this->parent); $this->set_reflection_property_value('method', 'GET'); - $property = $this->reflection->getProperty('body'); - $property->setAccessible(true); - $property->setValue($this->class, 1000); + $this->set_reflection_property_value('body', 1000); $struct = $this->getMockBuilder('\PHPDraft\Model\Elements\ObjectStructureElement') ->disableOriginalConstructor() @@ -227,10 +206,7 @@ public function testGetCurlCommandStructBodyFilled(): void ->will($this->returnValue('TEST')); $struct->value = [ $struct_ar ]; - - $property = $this->reflection->getProperty('struct'); - $property->setAccessible(true); - $property->setValue($this->class, $struct); + $this->set_reflection_property_value('struct', $struct); $return = $this->class->get_curl_command('https://ur.l'); @@ -249,10 +225,7 @@ public function testParseIsCalled(): void $this->class->parse(json_decode($obj)); $this->assertSame($this->parent, $this->get_reflection_property_value('parent')); - - $href_property = $this->reflection->getProperty('method'); - $href_property->setAccessible(true); - $this->assertSame('TEST', $href_property->getValue($this->class)); + $this->assertSame('TEST', $this->get_reflection_property_value('method')); } /** @@ -267,10 +240,7 @@ public function testParseIsCalledWithHeaders(): void $this->class->parse(json_decode($obj)); $this->assertSame($this->parent, $this->get_reflection_property_value('parent')); - - $href_property = $this->reflection->getProperty('headers'); - $href_property->setAccessible(true); - $this->assertSame(['KEY' => 'VALUE'], $href_property->getValue($this->class)); + $this->assertSame(['KEY' => 'VALUE'], $this->get_reflection_property_value('headers')); } /** @@ -285,14 +255,8 @@ public function testParseIsCalledWithPOST(): void $this->class->parse(json_decode($obj)); $this->assertSame($this->parent, $this->get_reflection_property_value('parent')); - - $struct_property = $this->reflection->getProperty('struct'); - $struct_property->setAccessible(true); - $this->assertSame([], $struct_property->getValue($this->class)); - - $body_property = $this->reflection->getProperty('body'); - $body_property->setAccessible(true); - $this->assertSame([], $body_property->getValue($this->class)); + $this->assertSame([], $this->get_reflection_property_value('struct')); + $this->assertSame([], $this->get_reflection_property_value('body')); } /** @@ -307,14 +271,8 @@ public function testParseIsCalledWithPOSTCopy(): void $this->class->parse(json_decode($obj)); $this->assertSame($this->parent, $this->get_reflection_property_value('parent')); - - $struct_property = $this->reflection->getProperty('struct'); - $struct_property->setAccessible(true); - $this->assertSame([], $struct_property->getValue($this->class)); - - $body_property = $this->reflection->getProperty('description'); - $body_property->setAccessible(true); - $this->assertSame('

text

' . PHP_EOL, $body_property->getValue($this->class)); + $this->assertEquals([], $this->get_reflection_property_value('struct')); + $this->assertEquals('text', $this->get_reflection_property_value('description')); } /** @@ -329,10 +287,7 @@ public function testParseIsCalledWithPOSTStruct(): void $this->class->parse(json_decode($obj)); $this->assertSame($this->parent, $this->get_reflection_property_value('parent')); - - $struct_property = $this->reflection->getProperty('struct'); - $struct_property->setAccessible(true); - $this->assertNotEmpty($struct_property->getValue($this->class)); + $this->assertNotEmpty($this->get_reflection_property_value('struct')); } /** @@ -347,13 +302,7 @@ public function testParseIsCalledWithPOSTAsset(): void $this->class->parse(json_decode($obj)); $this->assertSame($this->parent, $this->get_reflection_property_value('parent')); - - $struct_property = $this->reflection->getProperty('body'); - $struct_property->setAccessible(true); - $this->assertSame(['something'], $struct_property->getValue($this->class)); - - $header_property = $this->reflection->getProperty('headers'); - $header_property->setAccessible(true); - $this->assertSame(['Content-Type' => ''], $header_property->getValue($this->class)); + $this->assertSame(['something'], $this->get_reflection_property_value('body')); + $this->assertSame(['Content-Type' => ''], $this->get_reflection_property_value('headers')); } } diff --git a/src/PHPDraft/Model/Tests/HTTPResponseTest.php b/src/PHPDraft/Model/Tests/HTTPResponseTest.php index 2bef9f4a..f57bbcf9 100644 --- a/src/PHPDraft/Model/Tests/HTTPResponseTest.php +++ b/src/PHPDraft/Model/Tests/HTTPResponseTest.php @@ -83,19 +83,14 @@ public function testGetId(): void */ public function testParseIsCalled(): void { - $property = $this->reflection->getProperty('parent'); - $property->setAccessible(true); - $property->setValue($this->class, $this->parent); + $this->set_reflection_property_value('parent', $this->parent); $obj = '{"attributes":{"statusCode":1000, "headers":{"content":[]}}, "content":[]}'; $this->class->parse(json_decode($obj)); - $this->assertSame($this->parent, $property->getValue($this->class)); - - $href_property = $this->reflection->getProperty('statuscode'); - $href_property->setAccessible(true); - $this->assertSame(1000, $href_property->getValue($this->class)); + $this->assertSame($this->parent, $this->get_reflection_property_value('parent')); + $this->assertSame(1000, $this->get_reflection_property_value('statuscode')); } /** @@ -103,19 +98,14 @@ public function testParseIsCalled(): void */ public function testParseIsCalledExtraHeaders(): void { - $property = $this->reflection->getProperty('parent'); - $property->setAccessible(true); - $property->setValue($this->class, $this->parent); + $this->set_reflection_property_value('parent', $this->parent); $obj = '{"attributes":{"statusCode":1000, "headers":{"content":[{"content":{"key":{"content":"contentKEY"}, "value":{"content":"contentVALUE"}}}]}}, "content":[]}'; $this->class->parse(json_decode($obj)); - $this->assertSame($this->parent, $property->getValue($this->class)); - - $href_property = $this->reflection->getProperty('headers'); - $href_property->setAccessible(true); - $this->assertSame(['contentKEY' => 'contentVALUE'], $href_property->getValue($this->class)); + $this->assertSame($this->parent, $this->get_reflection_property_value('parent')); + $this->assertSame(['contentKEY' => 'contentVALUE'], $this->get_reflection_property_value('headers')); } /** @@ -123,19 +113,14 @@ public function testParseIsCalledExtraHeaders(): void */ public function testParseIsCalledWOAttributes(): void { - $property = $this->reflection->getProperty('parent'); - $property->setAccessible(true); - $property->setValue($this->class, $this->parent); + $this->set_reflection_property_value('parent', $this->parent); $obj = '{"content":[]}'; $this->class->parse(json_decode($obj)); - $this->assertSame($this->parent, $property->getValue($this->class)); - - $href_property = $this->reflection->getProperty('statuscode'); - $href_property->setAccessible(true); - $this->assertNull($href_property->getValue($this->class)); + $this->assertSame($this->parent, $this->get_reflection_property_value('parent')); + $this->assertNull($this->get_reflection_property_value('statuscode')); } /** @@ -143,19 +128,14 @@ public function testParseIsCalledWOAttributes(): void */ public function testParseIsCalledCopyContent(): void { - $property = $this->reflection->getProperty('parent'); - $property->setAccessible(true); - $property->setValue($this->class, $this->parent); + $this->set_reflection_property_value('parent', $this->parent); $obj = '{"content":[{"element":"copy", "content":""}]}'; $this->class->parse(json_decode($obj)); - $this->assertSame($this->parent, $property->getValue($this->class)); - - $href_property = $this->reflection->getProperty('description'); - $href_property->setAccessible(true); - $this->assertSame('' . PHP_EOL, $href_property->getValue($this->class)); + $this->assertSame($this->parent, $this->get_reflection_property_value('parent')); + $this->assertSame('', $this->get_reflection_property_value('description')); } /** @@ -163,19 +143,14 @@ public function testParseIsCalledCopyContent(): void */ public function testParseIsCalledStructContentEmpty(): void { - $property = $this->reflection->getProperty('parent'); - $property->setAccessible(true); - $property->setValue($this->class, $this->parent); + $this->set_reflection_property_value('parent', $this->parent); $obj = '{"content":[{"element":"dataStructure", "content":[]}]}'; $this->class->parse(json_decode($obj)); - $this->assertSame($this->parent, $property->getValue($this->class)); - - $href_property = $this->reflection->getProperty('structure'); - $href_property->setAccessible(true); - $this->assertEmpty($href_property->getValue($this->class)); + $this->assertSame($this->parent, $this->get_reflection_property_value('parent')); + $this->assertEmpty($this->get_reflection_property_value('structure')); } /** @@ -183,19 +158,14 @@ public function testParseIsCalledStructContentEmpty(): void */ public function testParseIsCalledStructContent(): void { - $property = $this->reflection->getProperty('parent'); - $property->setAccessible(true); - $property->setValue($this->class, $this->parent); + $this->set_reflection_property_value('parent', $this->parent); $obj = '{"content":[{"element":"dataStructure", "content":[{}]}]}'; $this->class->parse(json_decode($obj)); - $this->assertSame($this->parent, $property->getValue($this->class)); - - $href_property = $this->reflection->getProperty('structure'); - $href_property->setAccessible(true); - $this->assertNotEmpty($href_property->getValue($this->class)); + $this->assertSame($this->parent, $this->get_reflection_property_value('parent')); + $this->assertNotEmpty($this->get_reflection_property_value('structure')); } /** @@ -203,20 +173,14 @@ public function testParseIsCalledStructContent(): void */ public function testParseIsCalledStructContentHasAttr(): void { - $property = $this->reflection->getProperty('parent'); - $property->setAccessible(true); - $property->setValue($this->class, $this->parent); + $this->set_reflection_property_value('parent', $this->parent); $obj = '{"content":[{"content":"hello", "attributes":{"contentType":"content"}, "element":"hello"}]}'; $this->class->parse(json_decode($obj)); - $this->assertSame($this->parent, $property->getValue($this->class)); - - $href_property = $this->reflection->getProperty('content'); - $href_property->setAccessible(true); - $this->assertArrayHasKey('content', $href_property->getValue($this->class)); - $this->assertSame('hello', $href_property->getValue($this->class)['content']); + $this->assertArrayHasKey('content', $this->get_reflection_property_value('content')); + $this->assertSame('hello', $this->get_reflection_property_value('content')['content']); } /** @@ -224,9 +188,7 @@ public function testParseIsCalledStructContentHasAttr(): void */ public function testEqualOnStatusCode(): void { - $property = $this->reflection->getProperty('statuscode'); - $property->setAccessible(true); - $property->setValue($this->class, 200); + $this->set_reflection_property_value('statuscode', 200); $obj = '{"statuscode":200, "description":"hello"}'; @@ -240,9 +202,7 @@ public function testEqualOnStatusCode(): void */ public function testEqualOnDesc(): void { - $property = $this->reflection->getProperty('description'); - $property->setAccessible(true); - $property->setValue($this->class, 'hello'); + $this->set_reflection_property_value('description', 'hello'); $obj = '{"statuscode":300, "description":"hello"}'; @@ -256,17 +216,14 @@ public function testEqualOnDesc(): void */ public function testEqualOnBoth(): void { - $s_property = $this->reflection->getProperty('statuscode'); - $s_property->setAccessible(true); - $s_property->setValue($this->class, 200); + $this->set_reflection_property_value('statuscode', 200); + $this->set_reflection_property_value('description', 'hello'); - $property = $this->reflection->getProperty('description'); - $property->setAccessible(true); - $property->setValue($this->class, 'hello'); + $obj = '{"attributes":{"statusCode":200}, "content":[{"element":"copy", "content": "hello"}]}'; + $b = new HTTPResponse($this->parent_transition); + $b->parse(json_decode($obj)); - $obj = '{"statuscode":200, "description":"hello"}'; - - $return = $this->class->is_equal_to(json_decode($obj)); + $return = $this->class->is_equal_to($b); $this->assertTrue($return); } diff --git a/src/PHPDraft/Model/Tests/HierarchyElementTest.php b/src/PHPDraft/Model/Tests/HierarchyElementTest.php index 6b49d89f..7f8490ed 100644 --- a/src/PHPDraft/Model/Tests/HierarchyElementTest.php +++ b/src/PHPDraft/Model/Tests/HierarchyElementTest.php @@ -100,7 +100,7 @@ public function testParseIsCalledLoop(): void $href_property = $this->reflection->getProperty('description'); $href_property->setAccessible(true); - $this->assertSame('hello' . PHP_EOL, $href_property->getValue($this->class)); + $this->assertSame('hello', $href_property->getValue($this->class)); } /** @@ -124,7 +124,7 @@ public function testParseIsCalledSlice(): void $href_property = $this->reflection->getProperty('description'); $href_property->setAccessible(true); - $this->assertSame('hello' . PHP_EOL, $href_property->getValue($this->class)); + $this->assertSame('hello', $href_property->getValue($this->class)); } diff --git a/src/PHPDraft/Model/Transition.php b/src/PHPDraft/Model/Transition.php index 3b8011a7..266cbb0d 100644 --- a/src/PHPDraft/Model/Transition.php +++ b/src/PHPDraft/Model/Transition.php @@ -114,39 +114,29 @@ public function parse(stdClass $object): self if (!isset($transition_item->content)) { continue; } - $list = []; + foreach ($transition_item->content as $item) { - $value = null; - if (!in_array($item->element, ['httpRequest', 'httpResponse'])) { - continue; - } + $parsable = null; switch ($item->element) { case 'httpRequest': - $value = new HTTPRequest($this); - $list = &$this->requests; + $parsable = new HTTPRequest($this); + $val = $parsable->parse($item); + foreach ($this->requests as $request) { + if ($request->is_equal_to($val)) continue 3; + } + $this->requests[] = $val; break; case 'httpResponse': - $value = new HTTPResponse($this); - $list = &$this->responses; + $parsable = new HTTPResponse($this); + $val = $parsable->parse($item); + foreach ($this->responses as $response) { + if ($response->is_equal_to($val)) continue 3; + } + $this->responses[] = $parsable->parse($item); break; default: continue 2; } - $value->parse($item); - - if ($list === []) { - $list[] = $value; - continue; - } - $add = true; - foreach ($list as $existing_value) { - if ($existing_value->is_equal_to($value)) { - $add = false; - } - } - if ($add) { - $list[] = $value; - } } } @@ -266,11 +256,13 @@ public function get_method(int $request = 0): string /** * Generate a cURL request to run the transition. * - * @param string $base_url base URL of the server - * @param array $additional additional arguments to pass - * @param int $key number of the request to generate for + * @param string $base_url base URL of the server + * @param array $additional additional arguments to pass + * @param int $key number of the request to generate for * * @return string A cURL CLI command + * + * @throws \QL\UriTemplate\Exception If URL parts are invalid */ public function get_curl_command(string $base_url, array $additional = [], int $key = 0): string { diff --git a/src/PHPDraft/Out/BaseTemplateGenerator.php b/src/PHPDraft/Out/BaseTemplateRenderer.php similarity index 88% rename from src/PHPDraft/Out/BaseTemplateGenerator.php rename to src/PHPDraft/Out/BaseTemplateRenderer.php index 342adfea..02d4c592 100644 --- a/src/PHPDraft/Out/BaseTemplateGenerator.php +++ b/src/PHPDraft/Out/BaseTemplateRenderer.php @@ -15,7 +15,7 @@ use Lukasoppermann\Httpstatus\Httpstatus; use PHPDraft\Model\Elements\ObjectStructureElement; -abstract class BaseTemplateGenerator +abstract class BaseTemplateRenderer { /** * Type of sorting to do on objects. @@ -59,12 +59,6 @@ abstract class BaseTemplateGenerator * @var array */ protected $base_data; - /** - * The Http Status resolver. - * - * @var Httpstatus - */ - protected $http_status; /** * Structures used in all data. * diff --git a/src/PHPDraft/Out/HTML/default.phtml b/src/PHPDraft/Out/HTML/default.phtml deleted file mode 100644 index 1528b117..00000000 --- a/src/PHPDraft/Out/HTML/default.phtml +++ /dev/null @@ -1,335 +0,0 @@ - - */ -use PHPDraft\Out\Minifier; -?> - - - <?= $this->base_data['TITLE']; ?> - - - - - css as $style): ?> - - - -
-
-
-

base_data['TITLE']; ?> - base_data['ALT_HOST'])): ?> - - - base_data['HOST']; ?> - -

- base_data)):?> -

base_data['DESC']; ?>

- -
- image)): ?> -
- - Image - -
- -
-
- -
- categories as &$category): ?> - title)): ?> -

- title; ?> -

- - description)): ?> -

description; ?>

- - children as $resource): ?> -

- - title; ?> - - href; ?> -

- description)): ?> -

description; ?>

- - url_variables !== null): ?> -
URI Parameters
-
- - - - url_variables as $url_variable): ?> - - - -
keytypestatusdescriptionvalue
-
- - children as $transition): ?> -
-
-
- get_method(); ?> - href; ?> - - title; ?> - -
-
-
-

description; ?>

- requests !== []): ?> - requests as $key => $request): ?> -
-
-
Request - title)): ?> - title;?> - - -
-
- -
- description; ?> - - - -
Example URI
- base_data['HOST']; ?>build_url(); ?> - headers !== []): ?> -
Headers
-
    - headers as $name => $value): ?> -
  • - : - -
  • - -
- - body !== []): ?> -
Body
- body as $value): ?> - - - - headers['Content-Type'])) ? $request->headers['Content-Type'] : null; ?> - print_request($type); ?> - - - - - struct !== []): ?> -
Structure
-
- struct ?> -
- - - url_variables !== []): ?> -
URI Parameters
-
- - - - url_variables as $url_variable): ?> - - - -
keytypestatusdescriptionvalue
-
- - - data_variables !== null): ?> -
Request object
-
- data_variables ?> -
- -
-
- - - responses)): ?> - responses as $key => $response): ?> -
-
-
- Response statuscode." ".$this->http_status->getReasonPhrase($response->statuscode)?> - -
-
-
- description; ?> - headers !== []): ?> -
Headers
-
    - headers as $name => $value): ?> -
  • - : - -
  • - -
- - structure !== []): ?> -
Data Structure
-
- structure as $value): ?> - - -
- - content as $response_key => $value): ?> -
- get_id() . '-' . $response->statuscode . '-' . str_replace([ - '/', - '+', - '; ', - ';', - '=', - ], '-', $response_key); ?> -
- - - -
-
-
- -
-
- - -
-
- - - - base_structures) > 0): ?> -

Data structures

- base_structures as $key => $structure): ?> - - - -
-
-
-base_data, function ($value) { - return !in_array($value, ['HOST', 'TITLE', 'ALT_HOST', 'FORMAT', 'DESC', 'COLOR_1', 'COLOR_2']); -}, ARRAY_FILTER_USE_KEY); -if ($extras !== []): - $extras['host'] = $this->base_data['HOST']; ?> - - -js as $js): ?> - - - - - - - - - - \ No newline at end of file diff --git a/src/PHPDraft/Out/HTML/default/category.twig b/src/PHPDraft/Out/HTML/default/category.twig new file mode 100644 index 00000000..b1ace96e --- /dev/null +++ b/src/PHPDraft/Out/HTML/default/category.twig @@ -0,0 +1,11 @@ +
+{% if category.title %} +

{{ category.title }}

+{% endif %} +{% if category.description %} +

{{ category.description|markdown_to_html }}

+{% endif %} +{% for resource in category.children %} + {% include 'resource.twig' %} +{% endfor %} +
\ No newline at end of file diff --git a/src/PHPDraft/Out/HTML/default.css b/src/PHPDraft/Out/HTML/default/main.css similarity index 96% rename from src/PHPDraft/Out/HTML/default.css rename to src/PHPDraft/Out/HTML/default/main.css index b5dff222..9184e904 100644 --- a/src/PHPDraft/Out/HTML/default.css +++ b/src/PHPDraft/Out/HTML/default/main.css @@ -160,7 +160,7 @@ a.code { position: relative; } -.curl.btn, .hurl.btn { +.curl.btn { z-index: 999; position: absolute; top: 15px; @@ -172,12 +172,6 @@ a.code { border-bottom-left-radius: 0px } -.hurl.btn { - right: 54px; - border-top-right-radius: 0px; - border-bottom-right-radius: 0px -} - a.variable-key { color: inherit; } diff --git a/src/PHPDraft/Out/HTML/default.js b/src/PHPDraft/Out/HTML/default/main.js similarity index 100% rename from src/PHPDraft/Out/HTML/default.js rename to src/PHPDraft/Out/HTML/default/main.js diff --git a/src/PHPDraft/Out/HTML/default/main.twig b/src/PHPDraft/Out/HTML/default/main.twig new file mode 100644 index 00000000..b3399765 --- /dev/null +++ b/src/PHPDraft/Out/HTML/default/main.twig @@ -0,0 +1,82 @@ + + + + {{ data.TITLE }} + + + + + {% for style in css %} + + {% endfor %} + + + +
+
+
+

{{ data.TITLE|raw }} + {% if data.ALT_HOST %} + + {%- else %} + {{ data.HOST }} + {% endif %} +

+ {% if data.DESC %} + {{ data.DESC|markdown_to_html }} + {% endif %} +
+ {% if image %} +
+ + Image + +
+ {% endif %} +
+
+ {% include 'nav.twig' %} +
+ {% for category in categories %} + {% include 'category.twig' %} + {% endfor %} + {% if structures|length > 0 %} +

Data structures

+ {% for name,structure in structures %} + {% include 'structure.twig' %} + {% endfor %} + {% endif %} +
+
+
+{% if extra_data|length > 1 %} + +{% endif %} +{% for script in js %} + +{% endfor %} + + + + + + + + \ No newline at end of file diff --git a/src/PHPDraft/Out/HTML/default/nav.twig b/src/PHPDraft/Out/HTML/default/nav.twig new file mode 100644 index 00000000..c671f781 --- /dev/null +++ b/src/PHPDraft/Out/HTML/default/nav.twig @@ -0,0 +1,33 @@ + \ No newline at end of file diff --git a/src/PHPDraft/Out/HTML/default/resource.twig b/src/PHPDraft/Out/HTML/default/resource.twig new file mode 100644 index 00000000..884f75cd --- /dev/null +++ b/src/PHPDraft/Out/HTML/default/resource.twig @@ -0,0 +1,27 @@ +
+

+ + {{ resource.title }} + + {{ resource.href }} +

+{% if resource.description %} + {{ resource.description|markdown_to_html }} +{% endif %} +{% if resource.url_variables %} +
URI Parameters
+
+ + + + {% for url_variable in resource.url_variables %}{{ url_variable|raw }}{% endfor %} + +
keytypestatusdescriptionvalue
+
+{% endif %} +{% for transition in resource.children %} + {% include 'transition.twig' %} +{% endfor %} +
\ No newline at end of file diff --git a/src/PHPDraft/Out/HTML/default/structure.twig b/src/PHPDraft/Out/HTML/default/structure.twig new file mode 100644 index 00000000..fb554721 --- /dev/null +++ b/src/PHPDraft/Out/HTML/default/structure.twig @@ -0,0 +1,32 @@ + \ No newline at end of file diff --git a/src/PHPDraft/Out/HTML/default/transition.twig b/src/PHPDraft/Out/HTML/default/transition.twig new file mode 100644 index 00000000..7970b197 --- /dev/null +++ b/src/PHPDraft/Out/HTML/default/transition.twig @@ -0,0 +1,154 @@ +
+
+
+ {{ transition.get_method }} + {{ transition.href }} + + {{ transition.title }} + +
+
+
+ {% if transition.description %}{{ transition.description|markdown_to_html }}{% endif %} + {% if transition.requests|length > 0 %} + {% for request in transition.requests %} +
+
+
+ Request {% if request.title %}{{ request.title }}{% endif %} + +
+
+ +
+ {% if request.description %}{{ request.description|markdown_to_html }}{% endif %} + + + +
Example URI
+ {{ data.HOST }}{{ transaction.build_url }} + {% if request.headers|length > 0 %} +
Headers
+
    + {% for name,value in request.headers %} +
  • + + {{ name }}: {{ value }} + +
  • + {% endfor %} +
+ {% endif %} + {% if request.body|length > 0 %} +
Body
+ {% for value in request.body %} + {% if value is iterable %} + {{ value.print_request(request.headers.Content-Type|default(null)) }} + {{ value }} + {% else %} + {{ value }} + {% endif %} + {% endfor %} + {% endif %} + {% if request.struct|length > 0 %} +
Structure
+
{{ request.struct|raw }}
+ {% endif %} + + {% if transition.url_variables|length > 0 %} +
URI Parameters
+
+ + + + + + + + + + + + {% for url_variable in transition.url_variables %}{{ url_variable|raw }}{% endfor %} + +
keytypestatusdescriptionvalue
+
+ {% endif %} + + {% if transition.data_variables %} +
Request object
+
+ {{ transition.data_variables|raw }} +
+ {% endif %} +
+
+ {% endfor %} + {% endif %} + + {% if transition.responses is iterable %} + {% for response in transition.responses %} +
+
+
+ Response {{ response.statuscode }} {{ response.statuscode|status_reason }} + +
+
+
+ {% if response.description %}{{ response.description|markdown_to_html }}{% endif %} + {% if response.headers|length > 0 %} +
Headers
+
    + {% for name,value in response.headers %} +
  • + + {{name}}: {{ value }} + +
  • + {% endfor %} +
+ {% endif %} + {% if response.structure|length > 0 %} +
Data Structure
+
+ {% for value in response.structure %}{{ value|raw }}{% endfor %} +
+ {% endif %} + {% for response_key,value in response.content %} +
+ {% set sanitize_key = response_key|replace({'/':'-','+':'-',';':'-','=':'-'}) %} + {% set href = "#{response.get_id}-#{response.statuscode}-#{sanitize_key}" %} +
+ {{ response_key }} +
+
{{ value }}
+
+ {% endfor %} +
+
+ {% endfor %} + {% endif %} +
+
\ No newline at end of file diff --git a/src/PHPDraft/Out/HTML/material.css b/src/PHPDraft/Out/HTML/material.css deleted file mode 100644 index 2e5ac138..00000000 --- a/src/PHPDraft/Out/HTML/material.css +++ /dev/null @@ -1,167 +0,0 @@ -.phpdrafter-layout-transparent { - background: rgba(0,0,0,0) center / cover; -} -.phpdrafter-layout-transparent .mdl-layout__header, -.phpdrafter-layout-transparent .mdl-layout__drawer-button { - /* This background is dark, so we set text to white. Use 87% black instead if - your background is light. */ - color: white; -} -main { - width: 100%; -} - -.phpdrafter-card-wide.mdl-card { - width: 100%; - margin-bottom: 30px; -} -.phpdrafter-card-wide > .mdl-card__title { - color: #fff; - height: 176px; - background: #cccccc center / cover; -} -.phpdrafter-card-wide > .mdl-card__menu { - color: #fff; -} -h2.mdl-card__title-text { - display: inline-block; - width: 100%; -} -li.mdl-list__ite code{ - font-size: 12px; - font-weight: normal; -} - -.page-content { - width: 80%; - margin: 0px auto; -} -.pull-right { - text-align: right !important; - float: right !important; -} - -.text-success { - color: #3c763d; -} - -.text-warning { - color: #8a6d3b; -} - -.text-error { - color: #761c19; -} - -table.table p { - margin-bottom: 0px; -} - -div .mdl-card__supporting-text table { - width: 100%; - max-width: 100%; - border: 0px solid #000000; -} - -div .mdl-card__supporting-text { - width: 96%; - padding: 2%; -} - -.mdl-card__supporting-text .list-group-item.mdl-list__item{ - padding: 8px; - width: 100%; - clear: both; - display: block; - text-align: end; - font-size: 13px; - border-bottom: 1px solid #cccccc; - line-height: 31px; -} - -.mdl-card__supporting-text .list-group-item.mdl-list__item:last-of-type{ - border-bottom: 0px solid #cccccc; -} - -.showSearch { - background: #122b40 center / cover; - color: #cccccc; -} - -dialog { - width: 1000px !important; - height: -moz-fit-content; - height: -webkit-fit-content; - height: fit-content; - margin: auto; - border: solid; - padding: 1em; - background: white; - color: black; - display: block; -} - -dialog textarea { - width: 100%; - max-width: 100%; - line-break: strict; - word-break: break-all; - border-color: #cccccc; - height: 100%; -} -dialog .mdl-textfield { - width: 100%; -} - -dialog:not([open]) { - display: none; -} - -dialog + .backdrop { - position: fixed; - top: 0; right: 0; bottom: 0; left: 0; - background: rgba(0,0,0,0.1); -} - -._dialog_overlay { - position: fixed; - top: 0; right: 0; bottom: 0; left: 0; -} - -dialog.fixed { - position: fixed; - top: 50%; - transform: translate(0, -50%); -} - -body { - --put-color: rgb(248, 148, 6); - --post-color: rgb(98, 196, 98); - --get-color: rgb(91, 192, 222); - --delete-color: rgb(238, 95, 91); - --head-color: rgb(222, 121, 91); - --patch-color: rgb(196, 98, 196); -} - -.mdl-card__title a { - color: inherit; -} - -.PUT .mdl-card__title { - background: var(--put-color); -} -.POST .mdl-card__title { - background: var(--post-color); -} -.GET .mdl-card__title { - background: var(--get-color); -} -.DELETE .mdl-card__title { - background: var(--delete-color); -} -.HEAD .mdl-card__title { - background: var(--head-color); -} -.PATCH .mdl-card__title { - background: var(--patch-color); -} \ No newline at end of file diff --git a/src/PHPDraft/Out/HTML/material.phtml b/src/PHPDraft/Out/HTML/material.phtml deleted file mode 100644 index b121e0ce..00000000 --- a/src/PHPDraft/Out/HTML/material.phtml +++ /dev/null @@ -1,269 +0,0 @@ - - */ - -use PHPDraft\Out\Minifier; -use Enjoy\HttpStatusCode\Statuscodes; - -?> - - - - <?= $this->base_data['TITLE']; ?> - - - - css as $style): ?> - - - - - -
-
-
- - base_data['TITLE']; ?> -
-
-
-
- -
-
-
- categories as $category): ?> - title)): ?> -

title; ?>

- - description)): ?> -

description; ?>

- - children as $resource): ?> -

- title; ?> - href; ?> -

- description)): ?> -

description; ?>

- - children as $transition): ?> -
-
-

get_method(); ?> - href; ?> - title; ?>

-
-
- description; ?> - requests) || !is_null($transition->responses)): $i = 0;?> -
-
- requests !== []): ?> - requests as $request): ?> - - Request title ? '' : ' ' . $request->title) ?> - - - - responses !== []): ?> - responses as $response): ?> - statuscode; ?> - - -
- requests !== []): ?> - requests as $key => $request): ?> - -

CURL Command

-
- This might be useful for debugging -
- -
-
-
- -
-
-
- description; ?> -
Example URI
- base_data['HOST']; ?> - build_url(); ?> - headers !== []): ?> -
Headers
-
    - headers as $name => $value): ?> -
  • - - : - -
  • - -
- - body !== []): ?> -
Body
- body as $value): ?> - - - - headers['Content-Type'])) ? $request->headers['Content-Type'] : NULL; ?> - print_request($type); ?> - - - - - struct !== []): ?> -
Structure
- struct ?> - - url_variables !== []): ?> -
URI Parameters
- - - - url_variables as $url_variable): ?> - - - -
KeyTypeStatusDescriptionValue
- - data_variables !== NULL): ?> -
Request object
- data_variables ?> - -
- - - responses !== []): ?> - responses as $key => $response): ?> -
- description; ?> - headers !== []): ?> -
Headers
-
    - headers as $name => $value): ?> -
  • - - : - -
  • - -
- - structure !== []): ?> -
Data Structure
- structure as $value): ?> - - - -
- content as $response_key => $value): ?> -
-
-
-
- -
-
- - - - -
-
-
- - - - base_structures) > 0): ?> -

Data structures

- base_structures as $key => $structure): ?> -
-
-

-
-
- -
-
- - -
-
-
-base_data, function ($value) { - return !in_array($value, ['HOST', 'TITLE', 'ALT_HOST', 'FORMAT', 'DESC', 'COLOR_1', 'COLOR_2']); -}, ARRAY_FILTER_USE_KEY); -if ($extras !== []): - $extras['host'] = $this->base_data['HOST']; ?> - - -js as $js): ?> - - - - - - - - \ No newline at end of file diff --git a/src/PHPDraft/Out/HTML/material/category.twig b/src/PHPDraft/Out/HTML/material/category.twig new file mode 100644 index 00000000..b1ace96e --- /dev/null +++ b/src/PHPDraft/Out/HTML/material/category.twig @@ -0,0 +1,11 @@ +
+{% if category.title %} +

{{ category.title }}

+{% endif %} +{% if category.description %} +

{{ category.description|markdown_to_html }}

+{% endif %} +{% for resource in category.children %} + {% include 'resource.twig' %} +{% endfor %} +
\ No newline at end of file diff --git a/src/PHPDraft/Out/HTML/material/main.css b/src/PHPDraft/Out/HTML/material/main.css new file mode 100644 index 00000000..94d0139c --- /dev/null +++ b/src/PHPDraft/Out/HTML/material/main.css @@ -0,0 +1,242 @@ +div#navbar { + height: 100vh; + position: sticky; + top:0; +} + +var.url-param { + font-weight: bold; +} + +var.url-value { + color: #c90c00; + padding: 2px; +} + +div.main-url { + text-align: justify; + line-break: loose; + word-break: break-all; +} + +a.extra-info.btn { + position: fixed; + bottom: 10px; + right: 10px; + border-radius: 30px; + z-index: 999; +} + +span.variable-info { + margin-left: 10px; + background: rgba(0,0,0,.5); + padding: 5px 10px; + border-radius: 25px; + font-size: 0.7em; +} + +button.extra-info.btn:focus { + border-width: 0px; + box-shadow: none; + outline: 0; +} + +.request-card > code, .popover-content { + word-break: break-all; +} + +body .media h1.media-heading { + margin-top: 20px; + margin-bottom: 10px; +} + +body .media h1.media-heading .form-control { + display: flex; + width: auto; + float: right; +} + +div.card { + margin: 10px auto; +} + +.card-title a { + color: #000; +} +.card-title var, h4.response var { + padding: 6px 12px; + margin-right: 12px; + border-radius: 3px; + display: inline-block; + background: rgba(0, 0, 0, 0.1); +} + +h4.response.warning var { + background: rgba(255, 103, 8, 0.2); +} + +h4.response.error var { + background: rgba(201, 12, 0, 0.1); +} + +.card-title code { + color: #000; + background-color: rgba(255, 255, 255, 0.7); + padding: 1px 4px; + margin-top: 2px; + border: 1px solid transparent; + border-radius: 3px +} + +.card-title a.transition-title { + padding: 6px 0; +} + +body .col-md-10 h2:first-child, +body .col-md-10 h3:first-child { + margin-top: 0; +} + +@media (min-width: 768px) { + .method-nav { + max-height: 100vh; + overflow-x: visible; + overflow-y: scroll; + top: 0; + box-shadow: 0px -5px 5px -5px rgba(0, 0, 0, 0.2) inset, 0px 0px 1px rgba(102, 102, 102, 0.4); + } +} +.method-nav { + padding: 0px 10px; +} +.method-nav nav { + width: 100%; +} +.method-nav nav.category, +.method-nav nav.structures, +.method-nav nav.structures a.nav-link, +.method-nav nav.resource a.nav-link { + padding-left: 0px; +} + +.method-nav nav.resource .transition a.nav-link { + padding-left: .5rem; +} + +.method-nav a.nav-link { + line-height: 26px; + width: 100%; + display: block; +} + +.method-nav a.nav-link span { + float: right; +} + +.method-nav a.nav-link i { + color: #fff; + padding: 0 5px; + border-radius: 15px; + line-height: 22px; +} + +.main-content { + position: relative; +} + +.example-value { + color: rgba(0, 0, 0, 0.4); + text-align: right; +} + +a.code { + padding: 2px 4px; + font-size: 90%; + background-color: #f9f2f4; + border-radius: 4px; + font-family: Menlo, Monaco, Consolas, "Courier New", monospace; +} + +.popover { + width: auto; + max-width: 50%; +} + +.popover-content { + width: auto; + max-width: 100%; + line-break: normal; + white-space: pre-wrap; +} + +ul.collapsible li div.collapsible-body { + position: relative; +} + +.modal textarea { + height: 18rem; +} + +.curl.btn { + z-index: 999; + position: absolute; + top: 15px; + right: 15px; + border-top-left-radius: 0px; + border-bottom-left-radius: 0px +} + +a.variable-key { + color: inherit; +} + +body { + --put-color: rgb(248, 148, 6); + --post-color: rgb(98, 196, 98); + --get-color: rgb(91, 192, 222); + --delete-color: rgb(238, 95, 91); + --head-color: rgb(222, 121, 91); + --patch-color: rgb(196, 98, 196); +} + +.PUT:not(.structure) > .card-header{ + background: var(--put-color); +} +span.PUT { + color: var(--put-color); +} + +.POST:not(.structure) > .card-header{ + background: var(--post-color); +} +span.POST { + color: var(--post-color); +} + +.GET:not(.structure) > .card-header{ + background: var(--get-color); +} +span.GET { + color: var(--get-color); +} + +.DELETE:not(.structure) > .card-header{ + background: var(--delete-color); +} +span.DELETE { + color: var(--delete-color); +} + +.HEAD:not(.structure) > .card-header{ + background: var(--head-color); +} +span.HEAD { + color: var(--head-color); +} + +.PATCH:not(.structure) > .card-header{ + background: var(--patch-color); +} +span.PATCH { + color: var(--patch-color); +} \ No newline at end of file diff --git a/src/PHPDraft/Out/HTML/material.js b/src/PHPDraft/Out/HTML/material/main.js similarity index 59% rename from src/PHPDraft/Out/HTML/material.js rename to src/PHPDraft/Out/HTML/material/main.js index bd2f329d..7f232ca7 100644 --- a/src/PHPDraft/Out/HTML/material.js +++ b/src/PHPDraft/Out/HTML/material/main.js @@ -1,7 +1,3 @@ -/** - * Created by smillernl on 18-5-17. - */ - function getParameters() { let result = {}; let tmp = []; @@ -13,18 +9,32 @@ function getParameters() { .split("&") .forEach(function (item) {tmp = item.split("="); result[tmp[0]] = decodeURIComponent(tmp[1]); }); return result; -}; +} -anchors.options = { - placement: 'left', - visible: 'touch', -}; -anchors.add('.main-content h1, .main-content h2, .main-content h3, .main-content .card-header a'); +function escapeRegExp(str) { return str.replace(/[-\[\]/{}()*+?.\\^$|]/g, "\\$&"); }; -$(function () { +$(document).ready(function(){ $('[data-toggle="tooltip"]').tooltip(); + $('.collapsible').collapsible(); + $('.modal').modal(); + if (!localStorage.getItem('visited')) { + $('.tap-target').tapTarget().tapTarget('open'); + } + localStorage.setItem('visited', true); + let contentDom = $('body>div>div.row'); + let formControlDom = $('h1.media-heading select.form-control'); + let selectedhost = formControlDom.val(); + formControlDom.on('change', function () { + let html = contentDom.html(); + let re = new RegExp(escapeRegExp(selectedhost), 'g'); + let new_html = html.replace(re, formControlDom.val()); + selectedhost = formControlDom.val(); + contentDom.html(new_html); + trigger_popover(); + }); + let parameters = getParameters(); Object.keys(parameters).forEach(function(key) { let html = contentDom.html(); @@ -39,4 +49,10 @@ $(function () { .replace(curl_re, `-H '${key}: ${parameters[key]}'`); contentDom.html(new_html); }); -}); \ No newline at end of file +}); + +anchors.options = { + placement: 'left', + visible: 'touch', +}; +anchors.add('.main-content h1, .main-content h2, .main-content h3, .main-content .card-header a'); \ No newline at end of file diff --git a/src/PHPDraft/Out/HTML/material/main.twig b/src/PHPDraft/Out/HTML/material/main.twig new file mode 100644 index 00000000..39892435 --- /dev/null +++ b/src/PHPDraft/Out/HTML/material/main.twig @@ -0,0 +1,90 @@ + + + + {{ data.TITLE }} + + + + + + {% for style in css %} + + {% endfor %} + + + +
+
+
+

{{ data.TITLE|raw }} + {% if data.ALT_HOST %} + + {%- else %} + {{ data.HOST }} + {% endif %} +

+ {% if data.DESC %} + {{ data.DESC|markdown_to_html }} + {% endif %} +
+ {% if image %} +
+ + Image + +
+ {% endif %} +
+
+ {% include 'nav.twig' %} +
+ {% for category in categories %} + {% include 'category.twig' %} + {% endfor %} + {% if structures|length > 0 %} +

Data structures

+ {% for name,structure in structures %} + {% include 'structure.twig' %} + {% endfor %} + {% endif %} +
+
+
+{% if extra_data|length > 1 %} + info_outline + +
+
+
Metadata
+

This button shows the metadata for the API

+
+
+ +{% endif %} +{% for script in js %} + +{% endfor %} + + + + + + + + \ No newline at end of file diff --git a/src/PHPDraft/Out/HTML/material/nav.twig b/src/PHPDraft/Out/HTML/material/nav.twig new file mode 100644 index 00000000..ffb78ddc --- /dev/null +++ b/src/PHPDraft/Out/HTML/material/nav.twig @@ -0,0 +1,31 @@ + \ No newline at end of file diff --git a/src/PHPDraft/Out/HTML/material/resource.twig b/src/PHPDraft/Out/HTML/material/resource.twig new file mode 100644 index 00000000..884f75cd --- /dev/null +++ b/src/PHPDraft/Out/HTML/material/resource.twig @@ -0,0 +1,27 @@ +
+

+ + {{ resource.title }} + + {{ resource.href }} +

+{% if resource.description %} + {{ resource.description|markdown_to_html }} +{% endif %} +{% if resource.url_variables %} +
URI Parameters
+
+ + + + {% for url_variable in resource.url_variables %}{{ url_variable|raw }}{% endfor %} + +
keytypestatusdescriptionvalue
+
+{% endif %} +{% for transition in resource.children %} + {% include 'transition.twig' %} +{% endfor %} +
\ No newline at end of file diff --git a/src/PHPDraft/Out/HTML/material/structure.twig b/src/PHPDraft/Out/HTML/material/structure.twig new file mode 100644 index 00000000..ce41be7c --- /dev/null +++ b/src/PHPDraft/Out/HTML/material/structure.twig @@ -0,0 +1,32 @@ + \ No newline at end of file diff --git a/src/PHPDraft/Out/HTML/material/transition.twig b/src/PHPDraft/Out/HTML/material/transition.twig new file mode 100644 index 00000000..afc2f46d --- /dev/null +++ b/src/PHPDraft/Out/HTML/material/transition.twig @@ -0,0 +1,157 @@ +
+
+
+ {{ transition.get_method }} + {{ transition.href }} + + {{ transition.title }} + +
+
+
+ {% if transition.description %}{{ transition.description|markdown_to_html }}{% endif %} +
    + {% if transition.requests|length > 0 %} + {% for request in transition.requests %} +
  • +
    +
    + filter_dramaRequest {% if request.title %}{{ request.title }}{% endif %} +
    +
    +
    + {% if request.description %}{{ request.description|markdown_to_html }}{% endif %} + + +
    Example URI
    + {{ data.HOST }}{{ transaction.build_url }} + {% if request.headers|length > 0 %} +
    Headers
    +
      + {% for name,value in request.headers %} +
    • + + {{ name }}: {{ value }} + +
    • + {% endfor %} +
    + {% endif %} + {% if request.body|length > 0 %} +
    Body
    + {% for value in request.body %} + {% if value is iterable %} + {{ value.print_request(request.headers.Content-Type|default(null)) }} + {{ value }} + {% else %} + {{ value }} + {% endif %} + {% endfor %} + {% endif %} + {% if request.struct|length > 0 %} +
    Structure
    +
    {{ request.struct|raw }}
    + {% endif %} + + {% if transition.url_variables|length > 0 %} +
    URI Parameters
    +
    + + + + + + + + + + + + {% for url_variable in transition.url_variables %}{{ url_variable|raw }}{% endfor %} + +
    keytypestatusdescriptionvalue
    +
    + {% endif %} + + {% if transition.data_variables %} +
    Request object
    +
    + {{ transition.data_variables|raw }} +
    + {% endif %} +
    +
  • + {% endfor %} + {% endif %} + + {% if transition.responses is iterable %} + {% for response in transition.responses %} +
  • +
    + publishResponse {{ response.statuscode }} {{ response.statuscode|status_reason }} +
    +
    +
    + {% if response.description %}{{ response.description|markdown_to_html }}{% endif %} + {% if response.headers|length > 0 %} +
    Headers
    +
      + {% for name,value in response.headers %} +
    • + + {{ name }}: {{ value }} + +
    • + {% endfor %} +
    + {% endif %} + {% if response.structure|length > 0 %} +
    Data Structure
    +
    + {% for value in response.structure %}{{ value|raw }}{% endfor %} +
    + {% endif %} + {% for response_key,value in response.content %} +
    + {% set sanitize_key = response_key|replace({'/':'-','+':'-',';':'-','=':'-'}) %} + {% set href = "#{response.get_id}-#{response.statuscode}-#{sanitize_key}" %} +
    + {{ response_key }} +
    +
    {{ value }}
    +
    + {% endfor %} +
    +
    +
  • + {% endfor %} + {% endif %} +
+
+
\ No newline at end of file diff --git a/src/PHPDraft/Out/Minifier.php b/src/PHPDraft/Out/Minifier.php deleted file mode 100644 index d7ea32aa..00000000 --- a/src/PHPDraft/Out/Minifier.php +++ /dev/null @@ -1,393 +0,0 @@ -'; - - const X = "\x1A"; - - /** - * Minify given HTML. - * - * @param string $input input to minify - * - * @return string - */ - public static function minify_html($input) - { - if (!$input = trim($input)) { - return $input; - } - // Keep important white-space(s) after self-closing HTML tag(s) - $input = preg_replace('#(<(?:img|input)(?:\s[^<>]*?)?\s*\/?>)\s+#i', '$1' . self::X . '\s', $input); - // Create chunk(s) of HTML tag(s), ignored HTML group(s), HTML comment(s) and text - $input = - preg_split( - '#(' . self::CH . '||\s[^<>]*?>)[\s\S]*?<\/pre>||\s[^<>]*?>)[\s\S]*?<\/code>||\s[^<>]*?>)[\s\S]*?<\/script>||\s[^<>]*?>)[\s\S]*?<\/style>||\s[^<>]*?>)[\s\S]*?<\/textarea>|<[^<>]+?>)#i', - $input, - -1, - PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE - ); - $output = ''; - foreach ($input as $v) { - if ($v !== ' ' && trim($v) === '') { - continue; - } - if ($v[0] === '<' && substr($v, -1) === '>') { - if ($v[1] === '!' && strpos($v, '') { - continue; - } - $output .= $v; - } else { - $output .= self::__minify_x(self::_minify_html($v)); - } - } else { - // Force line-break with ` ` or ` ` - $v = str_replace([' ', ' ', ' '], self::X . '\n', $v); - // Force white-space with ` ` or ` ` - $v = str_replace([' ', ' '], self::X . '\s', $v); - // Replace multiple white-space(s) with a space - $output .= preg_replace('#\s+#', ' ', $v); - } - } - // Clean up ... - $output = preg_replace( - [ - // Remove two or more white-space(s) between tag [^1] - '#>([\n\r\t]\s*|\s{2,})<#', - // Remove white-space(s) before tag-close [^2] - '#\s+(<\/[^\s]+?>)#', - ], - [ - // [^1] - '><', - // [^2] - '$1', - ], - $output - ); - $output = self::__minify_v($output); - - // Remove white-space(s) after ignored tag-open and before ignored tag-close (except `"> - - -
Example URI
- https://owner-api.teslamotors.com/oauth/token - - -
Request object
-
-
grant_typestring

The type of oAuth grant. Always "password"

-
password
client_idstring

The oAuth client ID

-
abc
client_secretstring

The oAuth client secret

-
123
emailstring

The email for my.teslamotors.com

-
elon@teslamotors.com
passwordstring

The password for my.teslamotors.com

-
edisonsux
- - -
-
-
- Response 200 OK - -
+
+ + + +
Example URI
+ https://owner-api.teslamotors.com + + +
Request object
+
+
grant_typestring The type of oAuth grant. Always "password"password
client_idstring The oAuth client IDabc
client_secretstring The oAuth client secret123
emailstring The email for my.teslamotors.comelon@teslamotors.com
passwordstring The password for my.teslamotors.comedisonsux
+
-
-
Headers
-
    -
  • - Content-Type: application/json - -
  • -
-
-
- - application/json -
-
{
-  "access_token": "abc123",
-  "token_type": "bearer",
-  "expires_in": 7776000,
-  "created_at": 1457385291
+                
+ +
+
+
+ Response 200 OK + +
+
+
+
Headers
+
    +
  • + + Content-Type: application/json + +
  • +
+
+
+ application/json +
+
{
+  "access_token": "abc123",
+  "token_type": "bearer",
+  "expires_in": 7776000,
+  "created_at": 1457385291
 }
 
-
-
-
-
-
-

- Vehicles -

-

A logged in user can have multiple vehicles under their account. This resource is primarily responsible for listing the vehicles and the basic details about them. -

-

- - Vehicle Collection - /api/1/vehicles -

-
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
-
-
-
-
- GET - /api/1/vehicles - - List all Vehicles -
+
-
-

Retrieve a list of your owned vehicles (includes vehicles not yet shipped!) +

+
+
+

Vehicles

+

A logged in user can have multiple vehicles under their account. This resource is primarily responsible for listing the vehicles and the basic details about them.

-
-
-
Request - -
-
+
+

+ + Vehicle Collection + + /api/1/vehicles +

+
+
+
+ GET + /api/1/vehicles + + List all Vehicles + +
+
+
+

Retrieve a list of your owned vehicles (includes vehicles not yet shipped!)

+
+
+
+ Request +
+
-
- - - -
Example URI
- https://owner-api.teslamotors.com/api/1/vehicles -
Headers
-
    -
  • - Authorization: Bearer {access_token} - -
  • -
- - -
-
-
-
-
- Response 200 OK - -
+
+ + + +
Example URI
+ https://owner-api.teslamotors.com +
Headers
+
    +
  • + + Authorization: Bearer {access_token} + +
  • +
+ +
-
-
Headers
-
    -
  • - Content-Type: application/json - -
  • -
-
-
- - application/json -
-
{
-  "response": [{
-    "color": null,
-    "display_name": null,
-    "id": 321,
-    "option_codes": "MS01,RENA,TM00,DRLH,PF00,BT85,PBCW,RFPO,WT19,IBMB,IDPB,TR00,SU01,SC01,TP01,AU01,CH00,HP00,PA00,PS00,AD02,X020,X025,X001,X003,X007,X011,X013",
-    "user_id": 123,
-    "vehicle_id": 1234567890,
-    "vin": "5YJSA1CN5CFP01657",
-    "tokens": ["x", "x"],
-    "state": "online"
+                
+ +
+
+
+ Response 200 OK + +
+
+
+
Headers
+
    +
  • + + Content-Type: application/json + +
  • +
+
+
+ application/json +
+
{
+  "response": [{
+    "color": null,
+    "display_name": null,
+    "id": 321,
+    "option_codes": "MS01,RENA,TM00,DRLH,PF00,BT85,PBCW,RFPO,WT19,IBMB,IDPB,TR00,SU01,SC01,TP01,AU01,CH00,HP00,PA00,PS00,AD02,X020,X025,X001,X003,X007,X011,X013",
+    "user_id": 123,
+    "vehicle_id": 1234567890,
+    "vin": "5YJSA1CN5CFP01657",
+    "tokens": ["x", "x"],
+    "state": "online"
   }],
-  "count":1
+  "count":1
 }
 
-
-
-
-
-
-

- - State and Settings - /api/1/vehicles/{vehicle_id} -

-

These resources are read-only and determine the state of the vehicle's various sub-systems. -

-
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
vehicle_idstring required

The id of the Vehicle.

-
1
-
-
-
-
- GET - /api/1/vehicles/{vehicle_id}/mobile_enabled - - Mobile Access -
+
-
-

Determines if mobile access to the vehicle is enabled. -

-
-
-
Request - -
-
+
+
+
+

+ + State and Settings + + /api/1/vehicles/{vehicle_id} +

+

These resources are read-only and determine the state of the vehicle's various sub-systems.

-
- - - -
Example URI
- https://owner-api.teslamotors.com/api/1/vehicles/1/mobile_enabled -
Headers
-
    -
  • - Authorization: Bearer {access_token} - -
  • -
- -
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
vehicle_idstring required

The id of the Vehicle.

-
1
-
- -
-
-
-
-
- Response 200 OK - -
+
URI Parameters
+
+ + + + +
keytypestatusdescriptionvalue
vehicle_idstring requiredThe id of the Vehicle.1
+
+
+
+
+ GET + /api/1/vehicles/{vehicle_id}/mobile_enabled + + Mobile Access + +
+
+
+

Determines if mobile access to the vehicle is enabled.

+
+
+
+ Request +
+
+ +
+ + + +
Example URI
+ https://owner-api.teslamotors.com +
Headers
+
    +
  • + + Authorization: Bearer {access_token} + +
  • +
+ +
URI Parameters
+
+ + + + + + + + + + + + +
keytypestatusdescriptionvalue
vehicle_idstring requiredThe id of the Vehicle.1
+
+
-
-
Headers
-
    -
  • - Content-Type: application/json - -
  • -
-
-
- - application/json -
-
{
-    "response": true
+                
+ +
+
+
+ Response 200 OK + +
+
+
+
Headers
+
    +
  • + + Content-Type: application/json + +
  • +
+
+
+ application/json +
+
{
+    "response": true
 }
 
-
-
-
-
-
-
-
-
- GET - /api/1/vehicles/{vehicle_id}/data_request/charge_state - - Charge State -
+
-
-

Returns the state of charge in the battery. -

-
-
-
Request - -
-
+
+
+
+
+
+ GET + /api/1/vehicles/{vehicle_id}/data_request/charge_state + + Charge State + +
+
+
+

Returns the state of charge in the battery.

+
+
+
+ Request +
+
-
- - - -
Example URI
- https://owner-api.teslamotors.com/api/1/vehicles/1/data_request/charge_state -
Headers
-
    -
  • - Authorization: Bearer {access_token} - -
  • -
- -
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
vehicle_idstring required

The id of the Vehicle.

-
1
-
- -
-
-
-
-
- Response 200 OK - -
+
+ + + +
Example URI
+ https://owner-api.teslamotors.com +
Headers
+
    +
  • + + Authorization: Bearer {access_token} + +
  • +
+ +
URI Parameters
+
+ + + + + + + + + + + + +
keytypestatusdescriptionvalue
vehicle_idstring requiredThe id of the Vehicle.1
+
+
-
-
Headers
-
    -
  • - Content-Type: application/json - -
  • -
-
-
- - application/json -
-
{
-  "response": {
-    "charging_state": "Complete",  // "Charging", ??
-    "charge_to_max_range": false,  // current std/max-range setting
-    "max_range_charge_counter": 0,
-    "fast_charger_present": false, // connected to Supercharger?
-    "battery_range": 239.02,       // rated miles
-    "est_battery_range": 155.79,   // range estimated from recent driving
-    "ideal_battery_range": 275.09, // ideal miles
-    "battery_level": 91,           // integer charge percentage
-    "battery_current": -0.6,       // current flowing into battery
-    "charge_starting_range": null,
-    "charge_starting_soc": null,
-    "charger_voltage": 0,          // only has value while charging
-    "charger_pilot_current": 40,   // max current allowed by charger & adapter
-    "charger_actual_current": 0,   // current actually being drawn
-    "charger_power": 0,            // kW (rounded down) of charger
-    "time_to_full_charge": null,   // valid only while charging
-    "charge_rate": -1.0,           // float mi/hr charging or -1 if not charging
-    "charge_port_door_open": true
+                
+ +
+
+
+ Response 200 OK + +
+
+
+
Headers
+
    +
  • + + Content-Type: application/json + +
  • +
+
+
+ application/json +
+
{
+  "response": {
+    "charging_state": "Complete",  // "Charging", ??
+    "charge_to_max_range": false,  // current std/max-range setting
+    "max_range_charge_counter": 0,
+    "fast_charger_present": false, // connected to Supercharger?
+    "battery_range": 239.02,       // rated miles
+    "est_battery_range": 155.79,   // range estimated from recent driving
+    "ideal_battery_range": 275.09, // ideal miles
+    "battery_level": 91,           // integer charge percentage
+    "battery_current": -0.6,       // current flowing into battery
+    "charge_starting_range": null,
+    "charge_starting_soc": null,
+    "charger_voltage": 0,          // only has value while charging
+    "charger_pilot_current": 40,   // max current allowed by charger & adapter
+    "charger_actual_current": 0,   // current actually being drawn
+    "charger_power": 0,            // kW (rounded down) of charger
+    "time_to_full_charge": null,   // valid only while charging
+    "charge_rate": -1.0,           // float mi/hr charging or -1 if not charging
+    "charge_port_door_open": true
   }
 }
 
-
-
-
-
-
-
-
-
- GET - /api/1/vehicles/{vehicle_id}/data_request/climate_state - - Climate Settings -
+
-
-

Returns the current temperature and climate control state. -

-
-
-
Request - -
-
+
+
+
+
+
+ GET + /api/1/vehicles/{vehicle_id}/data_request/climate_state + + Climate Settings + +
+
+
+

Returns the current temperature and climate control state.

+
+
+
+ Request +
+
-
- - - -
Example URI
- https://owner-api.teslamotors.com/api/1/vehicles/1/data_request/climate_state -
Headers
-
    -
  • - Authorization: Bearer {access_token} - -
  • -
- -
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
vehicle_idstring required

The id of the Vehicle.

-
1
-
- -
-
-
-
-
- Response 200 OK - -
+
+ + + +
Example URI
+ https://owner-api.teslamotors.com +
Headers
+
    +
  • + + Authorization: Bearer {access_token} + +
  • +
+ +
URI Parameters
+
+ + + + + + + + + + + + +
keytypestatusdescriptionvalue
vehicle_idstring requiredThe id of the Vehicle.1
+
+
-
-
Headers
-
    -
  • - Content-Type: application/json - -
  • -
-
-
- - application/json -
-
{
-  "response": {
-    "inside_temp": 17.0,          // degC inside car
-    "outside_temp": 9.5,          // degC outside car or null
-    "driver_temp_setting": 22.6,  // degC of driver temperature setpoint
-    "passenger_temp_setting": 22.6, // degC of passenger temperature setpoint
-    "is_auto_conditioning_on": false, // apparently even if on
-    "is_front_defroster_on": null, // null or boolean as integer?
-    "is_rear_defroster_on": false,
-    "fan_status": 0               // fan speed 0-6 or null
+                
+ +
+
+
+ Response 200 OK + +
+
+
+
Headers
+
    +
  • + + Content-Type: application/json + +
  • +
+
+
+ application/json +
+
{
+  "response": {
+    "inside_temp": 17.0,          // degC inside car
+    "outside_temp": 9.5,          // degC outside car or null
+    "driver_temp_setting": 22.6,  // degC of driver temperature setpoint
+    "passenger_temp_setting": 22.6, // degC of passenger temperature setpoint
+    "is_auto_conditioning_on": false, // apparently even if on
+    "is_front_defroster_on": null, // null or boolean as integer?
+    "is_rear_defroster_on": false,
+    "fan_status": 0               // fan speed 0-6 or null
   }
 }
 
-
-
-
-
-
-
-
-
- GET - /api/1/vehicles/{vehicle_id}/data_request/drive_state - - Driving and Position -
+
-
-

Returns the driving and position state of the vehicle. -

-
-
-
Request - -
-
+
+
+
+
+
+ GET + /api/1/vehicles/{vehicle_id}/data_request/drive_state + + Driving and Position + +
+
+
+

Returns the driving and position state of the vehicle.

+
+
+
+ Request +
+
-
- - - -
Example URI
- https://owner-api.teslamotors.com/api/1/vehicles/1/data_request/drive_state -
Headers
-
    -
  • - Authorization: Bearer {access_token} - -
  • -
- -
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
vehicle_idstring required

The id of the Vehicle.

-
1
-
- -
-
-
-
-
- Response 200 OK - -
+
+ + + +
Example URI
+ https://owner-api.teslamotors.com +
Headers
+
    +
  • + + Authorization: Bearer {access_token} + +
  • +
+ +
URI Parameters
+
+ + + + + + + + + + + + +
keytypestatusdescriptionvalue
vehicle_idstring requiredThe id of the Vehicle.1
+
+
-
-
Headers
-
    -
  • - Content-Type: application/json - -
  • -
-
-
- - application/json -
-
{
-  "response": {
-    "shift_state": null,          //
-    "speed": null,                //
-    "latitude": 33.794839,        // degrees N of equator
-    "longitude": -84.401593,      // degrees W of the prime meridian
-    "heading": 4,                 // integer compass heading, 0-359
-    "gps_as_of": 1359863204       // Unix timestamp of GPS fix
+                
+ +
+
+
+ Response 200 OK + +
+
+
+
Headers
+
    +
  • + + Content-Type: application/json + +
  • +
+
+
+ application/json +
+
{
+  "response": {
+    "shift_state": null,          //
+    "speed": null,                //
+    "latitude": 33.794839,        // degrees N of equator
+    "longitude": -84.401593,      // degrees W of the prime meridian
+    "heading": 4,                 // integer compass heading, 0-359
+    "gps_as_of": 1359863204       // Unix timestamp of GPS fix
   }
 }
 
-
-
-
-
-
-
-
-
- GET - /api/1/vehicles/{vehicle_id}/data_request/gui_settings - - GUI Settings -
+
-
-

Returns various information about the GUI settings of the car, such as unit format and range display. -

-
-
-
Request - -
-
+
+
+
+
+
+ GET + /api/1/vehicles/{vehicle_id}/data_request/gui_settings + + GUI Settings + +
+
+
+

Returns various information about the GUI settings of the car, such as unit format and range display.

+
+
+
+ Request +
+
-
- - - -
Example URI
- https://owner-api.teslamotors.com/api/1/vehicles/1/data_request/gui_settings -
Headers
-
    -
  • - Authorization: Bearer {access_token} - -
  • -
- -
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
vehicle_idstring required

The id of the Vehicle.

-
1
-
- -
-
-
-
-
- Response 200 OK - -
+
+ + + +
Example URI
+ https://owner-api.teslamotors.com +
Headers
+
    +
  • + + Authorization: Bearer {access_token} + +
  • +
+ +
URI Parameters
+
+ + + + + + + + + + + + +
keytypestatusdescriptionvalue
vehicle_idstring requiredThe id of the Vehicle.1
+
+
-
-
Headers
-
    -
  • - Content-Type: application/json - -
  • -
-
-
- - application/json -
-
{
-  "response": {
-    "gui_distance_units": "mi/hr",
-    "gui_temperature_units": "F",
-    "gui_charge_rate_units": "mi/hr",
-    "gui_24_hour_time": false,
-    "gui_range_display": "Rated"
+                
+ +
+
+
+ Response 200 OK + +
+
+
+
Headers
+
    +
  • + + Content-Type: application/json + +
  • +
+
+
+ application/json +
+
{
+  "response": {
+    "gui_distance_units": "mi/hr",
+    "gui_temperature_units": "F",
+    "gui_charge_rate_units": "mi/hr",
+    "gui_24_hour_time": false,
+    "gui_range_display": "Rated"
   }
 }
 
-
-
-
-
-
-
-
-
- GET - /api/1/vehicles/{vehicle_id}/data_request/vehicle_state - - Vehicle State -
+
-
-

Returns the vehicle's physical state, such as which doors are open. -

-
-
-
Request - -
-
+
+
+
+
+
+ GET + /api/1/vehicles/{vehicle_id}/data_request/vehicle_state + + Vehicle State + +
+
+
+

Returns the vehicle's physical state, such as which doors are open.

+
+
+
+ Request +
+
-
- - - -
Example URI
- https://owner-api.teslamotors.com/api/1/vehicles/1/data_request/vehicle_state -
Headers
-
    -
  • - Authorization: Bearer {access_token} - -
  • -
- -
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
vehicle_idstring required

The id of the Vehicle.

-
1
-
- -
-
-
-
-
- Response 200 OK - -
+
+ + + +
Example URI
+ https://owner-api.teslamotors.com +
Headers
+
    +
  • + + Authorization: Bearer {access_token} + +
  • +
+ +
URI Parameters
+
+ + + + + + + + + + + + +
keytypestatusdescriptionvalue
vehicle_idstring requiredThe id of the Vehicle.1
+
+
-
-
Headers
-
    -
  • - Content-Type: application/json - -
  • -
-
-
- - application/json -
-
{
-  "response": {
-    "df": false,                  // driver's side front door open
-    "dr": false,                  // driver's side rear door open
-    "pf": false,                  // passenger's side front door open
-    "pr": false,                  // passenger's side rear door open
-    "ft": false,                  // front trunk is open
-    "rt": false,                  // rear trunk is open
-    "car_verson": "1.19.42",      // car firmware version
-    "locked": true,               // car is locked
-    "sun_roof_installed": false,  // panoramic roof is installed
-    "sun_roof_state": "unknown",
-    "sun_roof_percent_open": 0,   // null if not installed
-    "dark_rims": false,           // gray rims installed
-    "wheel_type": "Base19",       // wheel type installed
-    "has_spoiler": false,         // spoiler is installed
-    "roof_color": "Colored",      // "None" for panoramic roof
-    "perf_config": "Base"
+                
+ +
+
+
+ Response 200 OK + +
+
+
+
Headers
+
    +
  • + + Content-Type: application/json + +
  • +
+
+
+ application/json +
+
{
+  "response": {
+    "df": false,                  // driver's side front door open
+    "dr": false,                  // driver's side rear door open
+    "pf": false,                  // passenger's side front door open
+    "pr": false,                  // passenger's side rear door open
+    "ft": false,                  // front trunk is open
+    "rt": false,                  // rear trunk is open
+    "car_verson": "1.19.42",      // car firmware version
+    "locked": true,               // car is locked
+    "sun_roof_installed": false,  // panoramic roof is installed
+    "sun_roof_state": "unknown",
+    "sun_roof_percent_open": 0,   // null if not installed
+    "dark_rims": false,           // gray rims installed
+    "wheel_type": "Base19",       // wheel type installed
+    "has_spoiler": false,         // spoiler is installed
+    "roof_color": "Colored",      // "None" for panoramic roof
+    "perf_config": "Base"
   }
 }
 
-
-
-
-
-
-

- Vehicle Commands -

-

These commands alter the vehicles state, and return result (true/false) to indicate success, and if failure reason contains the cause of failure. -

-

- - Wake Up Car - /api/1/vehicles/{vehicle_id}/wake_up -

-
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
-
-
-
-
- POST - /api/1/vehicles/{vehicle_id}/wake_up - - Wake Up Car -
+
-
-

Wakes up the car from the sleep state. Necessary to get some data from the car. +

+
+
+

Vehicle Commands

+

These commands alter the vehicles state, and return result (true/false) to indicate success, and if failure reason contains the cause of failure.

-
-
-
Request - -
-
+
+

+ + Wake Up Car + + /api/1/vehicles/{vehicle_id}/wake_up +

+
+
+
+ POST + /api/1/vehicles/{vehicle_id}/wake_up + + Wake Up Car + +
+
+
+

Wakes up the car from the sleep state. Necessary to get some data from the car.

+
+
+
+ Request +
+
-
- - - -
Example URI
- https://owner-api.teslamotors.com/api/1/vehicles/1/wake_up -
Headers
-
    -
  • - Authorization: Bearer {access_token} - -
  • -
- -
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
vehicle_idstring required

The id of the Vehicle.

-
1
-
- -
-
-
-
-
- Response 200 OK - -
+
+ + + +
Example URI
+ https://owner-api.teslamotors.com +
Headers
+
    +
  • + + Authorization: Bearer {access_token} + +
  • +
+ +
URI Parameters
+
+ + + + + + + + + + + + +
keytypestatusdescriptionvalue
vehicle_idstring requiredThe id of the Vehicle.1
+
+
-
-
Headers
-
    -
  • - Content-Type: application/json - -
  • -
-
-
- - application/json -
-
{
-  "response": {
-    "result": true,
-    "reason": ""
+                
+ +
+
+
+ Response 200 OK + +
+
+
+
Headers
+
    +
  • + + Content-Type: application/json + +
  • +
+
+
+ application/json +
+
{
+  "response": {
+    "result": true,
+    "reason": ""
   }
 }
 
-
-
-
-
-
-

- - Set Valet Mode - /api/1/vehicles/{vehicle_id}/command/set_valet_mode -

-
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
-
-
-
-
- POST - /api/1/vehicles/{vehicle_id}/command/set_valet_mode - - Set Valet Mode -
+
-
-

Sets valet mode on or off with a PIN to disable it from within the car. Reuses last PIN from previous valet session. -Valet Mode limits the car's top speed to 70MPH and 80kW of acceleration power. It also disables Homelink, Bluetooth and -Wifi settings, and the ability to disable mobile access to the car. It also hides your favorites, home, and work -locations in navigation. -

-
-
-
Request - -
-
+
+
+
+

+ + Set Valet Mode + + /api/1/vehicles/{vehicle_id}/command/set_valet_mode +

+
+
+
+ POST + /api/1/vehicles/{vehicle_id}/command/set_valet_mode + + Set Valet Mode + +
+
+
+

Sets valet mode on or off with a PIN to disable it from within the car. Reuses last PIN from previous valet session.
+Valet Mode limits the car's top speed to 70MPH and 80kW of acceleration power. It also disables Homelink, Bluetooth and
+Wifi settings, and the ability to disable mobile access to the car. It also hides your favorites, home, and work
+locations in navigation.

+
+
+
+ Request +
+
-
- - - -
Example URI
- https://owner-api.teslamotors.com/api/1/vehicles/1/command/set_valet_mode -
Headers
-
    -
  • - Authorization: Bearer {access_token} - -
  • -
- -
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
vehicle_idstring required

The id of the Vehicle.

-
1
-
- -
Request object
-
-
onboolean

Whether to enable or disable valet mode.

-
true
passwordnumber

(optional) A 4 digit PIN code to unlock the car.

-
1234
-
-
-
-
-
- Response 200 OK - -
+
+ + + +
Example URI
+ https://owner-api.teslamotors.com +
Headers
+
    +
  • + + Authorization: Bearer {access_token} + +
  • +
+ +
URI Parameters
+
+ + + + + + + + + + + + +
keytypestatusdescriptionvalue
vehicle_idstring requiredThe id of the Vehicle.1
+
+ +
Request object
+
+
onboolean Whether to enable or disable valet mode.true
passwordnumber (optional) A 4 digit PIN code to unlock the car.1234
+
-
-
Headers
-
    -
  • - Content-Type: application/json - -
  • -
-
-
- - application/json -
-
{
-  "response": {
-    "result": true,
-    "reason": ""
+                
+ +
+
+
+ Response 200 OK + +
+
+
+
Headers
+
    +
  • + + Content-Type: application/json + +
  • +
+
+
+ application/json +
+
{
+  "response": {
+    "result": true,
+    "reason": ""
   }
 }
 
-
-
-
-
-
-

- - Reset Valet PIN - /api/1/vehicles/{vehicle_id}/command/reset_valet_pin -

-
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
-
-
-
-
- POST - /api/1/vehicles/{vehicle_id}/command/reset_valet_pin - - Reset Valet PIN -
+
-
-

Resets the PIN set for valet mode, if set. -

-
-
-
Request - -
-
+
+
+
+

+ + Reset Valet PIN + + /api/1/vehicles/{vehicle_id}/command/reset_valet_pin +

+
+
+
+ POST + /api/1/vehicles/{vehicle_id}/command/reset_valet_pin + + Reset Valet PIN + +
+
+
+

Resets the PIN set for valet mode, if set.

+
+
+
+ Request +
+
-
- - - -
Example URI
- https://owner-api.teslamotors.com/api/1/vehicles/1/command/reset_valet_pin -
Headers
-
    -
  • - Authorization: Bearer {access_token} - -
  • -
- -
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
vehicle_idstring required

The id of the Vehicle.

-
1
-
- -
-
-
-
-
- Response 200 OK - -
+
+ + + +
Example URI
+ https://owner-api.teslamotors.com +
Headers
+
    +
  • + + Authorization: Bearer {access_token} + +
  • +
+ +
URI Parameters
+
+ + + + + + + + + + + + +
keytypestatusdescriptionvalue
vehicle_idstring requiredThe id of the Vehicle.1
+
+
-
-
Headers
-
    -
  • - Content-Type: application/json - -
  • -
-
-
- - application/json -
-
{
-  "response": {
-    "result": true,
-    "reason": ""
+                
+ +
+
+
+ Response 200 OK + +
+
+
+
Headers
+
    +
  • + + Content-Type: application/json + +
  • +
+
+
+ application/json +
+
{
+  "response": {
+    "result": true,
+    "reason": ""
   }
 }
 
-
-
-
-
-
-

- - Open Charge Port - /api/1/vehicles/{vehicle_id}/command/charge_port_door_open -

-
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
-
-
-
-
- POST - /api/1/vehicles/{vehicle_id}/command/charge_port_door_open - - Open Charge Port -
+
-
-

Opens the charge port. Does not close the charge port (for now...) -

-
-
-
Request - -
-
+
+
+
+

+ + Open Charge Port + + /api/1/vehicles/{vehicle_id}/command/charge_port_door_open +

+
+
+
+ POST + /api/1/vehicles/{vehicle_id}/command/charge_port_door_open + + Open Charge Port + +
+
+
+

Opens the charge port. Does not close the charge port (for now...)

+
+
+
+ Request +
+
-
- - - -
Example URI
- https://owner-api.teslamotors.com/api/1/vehicles/1/command/charge_port_door_open -
Headers
-
    -
  • - Authorization: Bearer {access_token} - -
  • -
- -
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
vehicle_idstring required

The id of the Vehicle.

-
1
-
- -
-
-
-
-
- Response 200 OK - -
+
+ + + +
Example URI
+ https://owner-api.teslamotors.com +
Headers
+
    +
  • + + Authorization: Bearer {access_token} + +
  • +
+ +
URI Parameters
+
+ + + + + + + + + + + + +
keytypestatusdescriptionvalue
vehicle_idstring requiredThe id of the Vehicle.1
+
+
-
-
Headers
-
    -
  • - Content-Type: application/json - -
  • -
-
-
- - application/json -
-
{
-  "response": {
-    "result": true,
-    "reason": ""
+                
+ +
+
+
+ Response 200 OK + +
+
+
+
Headers
+
    +
  • + + Content-Type: application/json + +
  • +
+
+
+ application/json +
+
{
+  "response": {
+    "result": true,
+    "reason": ""
   }
 }
 
-
-
-
-
-
-

- - Set Charge Limit to Standard - /api/1/vehicles/{vehicle_id}/command/charge_standard -

-
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
-
-
-
-
- POST - /api/1/vehicles/{vehicle_id}/command/charge_standard - - Set Charge Limit to Standard -
+
-
-

Set the charge mode to standard (90% under the new percentage system introduced in 4.5). -

-
-
-
Request - -
-
+
+
+
+

+ + Set Charge Limit to Standard + + /api/1/vehicles/{vehicle_id}/command/charge_standard +

+
+
+
+ POST + /api/1/vehicles/{vehicle_id}/command/charge_standard + + Set Charge Limit to Standard + +
+
+
+

Set the charge mode to standard (90% under the new percentage system introduced in 4.5).

+
+
+
+ Request +
+
-
- - - -
Example URI
- https://owner-api.teslamotors.com/api/1/vehicles/1/command/charge_standard -
Headers
-
    -
  • - Authorization: Bearer {access_token} - -
  • -
- -
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
vehicle_idstring required

The id of the Vehicle.

-
1
-
- -
-
-
-
-
- Response 200 OK - -
+
+ + + +
Example URI
+ https://owner-api.teslamotors.com +
Headers
+
    +
  • + + Authorization: Bearer {access_token} + +
  • +
+ +
URI Parameters
+
+ + + + + + + + + + + + +
keytypestatusdescriptionvalue
vehicle_idstring requiredThe id of the Vehicle.1
+
+
-
-
Headers
-
    -
  • - Content-Type: application/json - -
  • -
-
-
- - application/json -
-
{
-  "response": {
-    "result": false,
-    "reason": "already_standard"
+                
+ +
+
+
+ Response 200 OK + +
+
+
+
Headers
+
    +
  • + + Content-Type: application/json + +
  • +
+
+
+ application/json +
+
{
+  "response": {
+    "result": false,
+    "reason": "already_standard"
   }
 }
 
-
-
-
-
-
-

- - Set Charge Limit to Max Range - /api/1/vehicles/{vehicle_id}/command/charge_max_range -

-
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
-
-
-
-
- POST - /api/1/vehicles/{vehicle_id}/command/charge_max_range - - Set Charge Limit to Max Range -
+
-
-

Set the charge mode to max range (100% under the new percentage system introduced in 4.5). Use sparingly! -

-
-
-
Request - -
-
+
+
+
+

+ + Set Charge Limit to Max Range + + /api/1/vehicles/{vehicle_id}/command/charge_max_range +

+
+
+
+ POST + /api/1/vehicles/{vehicle_id}/command/charge_max_range + + Set Charge Limit to Max Range + +
+
+
+

Set the charge mode to max range (100% under the new percentage system introduced in 4.5). Use sparingly!

+
+
+
+ Request +
+
-
- - - -
Example URI
- https://owner-api.teslamotors.com/api/1/vehicles/1/command/charge_max_range -
Headers
-
    -
  • - Authorization: Bearer {access_token} - -
  • -
- -
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
vehicle_idstring required

The id of the Vehicle.

-
1
-
- -
-
-
-
-
- Response 200 OK - -
+
+ + + +
Example URI
+ https://owner-api.teslamotors.com +
Headers
+
    +
  • + + Authorization: Bearer {access_token} + +
  • +
+ +
URI Parameters
+
+ + + + + + + + + + + + +
keytypestatusdescriptionvalue
vehicle_idstring requiredThe id of the Vehicle.1
+
+
-
-
Headers
-
    -
  • - Content-Type: application/json - -
  • -
-
-
- - application/json -
-
{
-  "response": {
-    "result": false,
-    "reason": "already_max_range"
+                
+ +
+
+
+ Response 200 OK + +
+
+
+
Headers
+
    +
  • + + Content-Type: application/json + +
  • +
+
+
+ application/json +
+
{
+  "response": {
+    "result": false,
+    "reason": "already_max_range"
   }
 }
 
-
-
-
-
-
-

- - Set Charge Limit - /api/1/vehicles/{vehicle_id}/command/set_charge_limit?percent={limit_value} -

-
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
-
-
-
-
- POST - /api/1/vehicles/{vehicle_id}/command/set_charge_limit?percent={limit_value} - - Set Charge Limit -
+
-
-

Set the charge limit to a custom percentage. -

-
-
-
Request - -
-
+
+
+
+

+ + Set Charge Limit + + /api/1/vehicles/{vehicle_id}/command/set_charge_limit?percent={limit_value} +

+
+
+
+ POST + /api/1/vehicles/{vehicle_id}/command/set_charge_limit?percent={limit_value} + + Set Charge Limit + +
+
+
+

Set the charge limit to a custom percentage.

+
+
+
+ Request +
+
-
- - - -
Example URI
- https://owner-api.teslamotors.com/api/1/vehicles/1/command/set_charge_limit?percent=75 -
Headers
-
    -
  • - Authorization: Bearer {access_token} - -
  • -
- -
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
vehicle_idstring required

The id of the Vehicle.

-
1
limit_valuestring required

The percentage value

-
75
-
- -
-
-
-
-
- Response 200 OK - -
+
+ + + +
Example URI
+ https://owner-api.teslamotors.com +
Headers
+
    +
  • + + Authorization: Bearer {access_token} + +
  • +
+ +
URI Parameters
+
+ + + + + + + + + + + + +
keytypestatusdescriptionvalue
vehicle_idstring requiredThe id of the Vehicle.1
limit_valuestring requiredThe percentage value75
+
+
-
-
Headers
-
    -
  • - Content-Type: application/json - -
  • -
-
-
- - application/json -
-
{
-  "response": {
-    "result": true,
-    "reason": ""
+                
+ +
+
+
+ Response 200 OK + +
+
+
+
Headers
+
    +
  • + + Content-Type: application/json + +
  • +
+
+
+ application/json +
+
{
+  "response": {
+    "result": true,
+    "reason": ""
   }
 }
 
-
-
-
-
-
-

- - Start Charging - /api/1/vehicles/{vehicle_id}/command/charge_start -

-
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
-
-
-
-
- POST - /api/1/vehicles/{vehicle_id}/command/charge_start - - Start Charging -
+
-
-

Start charging. Must be plugged in, have power available, and not have reached your charge limit. -

-
-
-
Request - -
-
+
+
+
+

+ + Start Charging + + /api/1/vehicles/{vehicle_id}/command/charge_start +

+
+
+
+ POST + /api/1/vehicles/{vehicle_id}/command/charge_start + + Start Charging + +
+
+
+

Start charging. Must be plugged in, have power available, and not have reached your charge limit.

+
+
+
+ Request +
+
-
- - - -
Example URI
- https://owner-api.teslamotors.com/api/1/vehicles/1/command/charge_start -
Headers
-
    -
  • - Authorization: Bearer {access_token} - -
  • -
- -
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
vehicle_idstring required

The id of the Vehicle.

-
1
-
- -
-
-
-
-
- Response 200 OK - -
+
+ + + +
Example URI
+ https://owner-api.teslamotors.com +
Headers
+
    +
  • + + Authorization: Bearer {access_token} + +
  • +
+ +
URI Parameters
+
+ + + + + + + + + + + + +
keytypestatusdescriptionvalue
vehicle_idstring requiredThe id of the Vehicle.1
+
+
-
-
Headers
-
    -
  • - Content-Type: application/json - -
  • -
-
-
- - application/json -
-
{
-  "response": {
-    "result": true,
-    "reason": "" // "already_started" if a charge is in progress
+                
+ +
+
+
+ Response 200 OK + +
+
+
+
Headers
+
    +
  • + + Content-Type: application/json + +
  • +
+
+
+ application/json +
+
{
+  "response": {
+    "result": true,
+    "reason": "" // "already_started" if a charge is in progress
   }
 }
 
-
-
-
-
-
-

- - Stop Charging - /api/1/vehicles/{vehicle_id}/command/charge_stop -

-
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
-
-
-
-
- POST - /api/1/vehicles/{vehicle_id}/command/charge_stop - - Stop Charging -
+
-
-

Stop charging. Must already be charging. -

-
-
-
Request - -
-
+
+
+
+

+ + Stop Charging + + /api/1/vehicles/{vehicle_id}/command/charge_stop +

+
+
+
+ POST + /api/1/vehicles/{vehicle_id}/command/charge_stop + + Stop Charging + +
+
+
+

Stop charging. Must already be charging.

+
+
+
+ Request +
+
-
- - - -
Example URI
- https://owner-api.teslamotors.com/api/1/vehicles/1/command/charge_stop -
Headers
-
    -
  • - Authorization: Bearer {access_token} - -
  • -
- -
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
vehicle_idstring required

The id of the Vehicle.

-
1
-
- -
-
-
-
-
- Response 200 OK - -
+
+ + + +
Example URI
+ https://owner-api.teslamotors.com +
Headers
+
    +
  • + + Authorization: Bearer {access_token} + +
  • +
+ +
URI Parameters
+
+ + + + + + + + + + + + +
keytypestatusdescriptionvalue
vehicle_idstring requiredThe id of the Vehicle.1
+
+
-
-
Headers
-
    -
  • - Content-Type: application/json - -
  • -
-
-
- - application/json -
-
{
-  "response": {
-    "result": true,
-    "reason": "" // "not_charging" if a charge was not in progress
+                
+ +
+
+
+ Response 200 OK + +
+
+
+
Headers
+
    +
  • + + Content-Type: application/json + +
  • +
+
+
+ application/json +
+
{
+  "response": {
+    "result": true,
+    "reason": "" // "not_charging" if a charge was not in progress
   }
 }
 
-
-
-
-
-
-

- - Flash Lights - /api/1/vehicles/{vehicle_id}/command/flash_lights -

-
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
-
-
-
-
- POST - /api/1/vehicles/{vehicle_id}/command/flash_lights - - Flash Lights -
+
-
-

Flash the lights once. -

-
-
-
Request - -
-
+
+
+
+

+ + Flash Lights + + /api/1/vehicles/{vehicle_id}/command/flash_lights +

+
+
+
+ POST + /api/1/vehicles/{vehicle_id}/command/flash_lights + + Flash Lights + +
+
+
+

Flash the lights once.

+
+
+
+ Request +
+
-
- - - -
Example URI
- https://owner-api.teslamotors.com/api/1/vehicles/1/command/flash_lights -
Headers
-
    -
  • - Authorization: Bearer {access_token} - -
  • -
- -
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
vehicle_idstring required

The id of the Vehicle.

-
1
-
- -
-
-
-
-
- Response 200 OK - -
+
+ + + +
Example URI
+ https://owner-api.teslamotors.com +
Headers
+
    +
  • + + Authorization: Bearer {access_token} + +
  • +
+ +
URI Parameters
+
+ + + + + + + + + + + + +
keytypestatusdescriptionvalue
vehicle_idstring requiredThe id of the Vehicle.1
+
+
-
-
Headers
-
    -
  • - Content-Type: application/json - -
  • -
-
-
- - application/json -
-
{
-  "response": {
-    "result": true,
-    "reason": ""
+                
+ +
+
+
+ Response 200 OK + +
+
+
+
Headers
+
    +
  • + + Content-Type: application/json + +
  • +
+
+
+ application/json +
+
{
+  "response": {
+    "result": true,
+    "reason": ""
   }
 }
 
-
-
-
-
-
-

- - Honk Horn - /api/1/vehicles/{vehicle_id}/command/honk_horn -

-
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
-
-
-
-
- POST - /api/1/vehicles/{vehicle_id}/command/honk_horn - - Honk Horn -
+
-
-

Honk the horn once. -

-
-
-
Request - -
-
+
+
+
+

+ + Honk Horn + + /api/1/vehicles/{vehicle_id}/command/honk_horn +

+
+
+
+ POST + /api/1/vehicles/{vehicle_id}/command/honk_horn + + Honk Horn + +
+
+
+

Honk the horn once.

+
+
+
+ Request +
+
-
- - - -
Example URI
- https://owner-api.teslamotors.com/api/1/vehicles/1/command/honk_horn -
Headers
-
    -
  • - Authorization: Bearer {access_token} - -
  • -
- -
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
vehicle_idstring required

The id of the Vehicle.

-
1
-
- -
-
-
-
-
- Response 200 OK - -
+
+ + + +
Example URI
+ https://owner-api.teslamotors.com +
Headers
+
    +
  • + + Authorization: Bearer {access_token} + +
  • +
+ +
URI Parameters
+
+ + + + + + + + + + + + +
keytypestatusdescriptionvalue
vehicle_idstring requiredThe id of the Vehicle.1
+
+
-
-
Headers
-
    -
  • - Content-Type: application/json - -
  • -
-
-
- - application/json -
-
{
-  "response": {
-    "result": true,
-    "reason": ""
+                
+ +
+
+
+ Response 200 OK + +
+
+
+
Headers
+
    +
  • + + Content-Type: application/json + +
  • +
+
+
+ application/json +
+
{
+  "response": {
+    "result": true,
+    "reason": ""
   }
 }
 
-
-
-
-
-
-

- - Unlock Doors - /api/1/vehicles/{vehicle_id}/command/door_unlock -

-
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
-
-
-
-
- POST - /api/1/vehicles/{vehicle_id}/command/door_unlock - - Unlock Doors -
+
-
-

Unlock the car's doors. -

-
-
-
Request - -
-
+
+
+
+

+ + Unlock Doors + + /api/1/vehicles/{vehicle_id}/command/door_unlock +

+
+
+
+ POST + /api/1/vehicles/{vehicle_id}/command/door_unlock + + Unlock Doors + +
+
+
+

Unlock the car's doors.

+
+
+
+ Request +
+
-
- - - -
Example URI
- https://owner-api.teslamotors.com/api/1/vehicles/1/command/door_unlock -
Headers
-
    -
  • - Authorization: Bearer {access_token} - -
  • -
- -
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
vehicle_idstring required

The id of the Vehicle.

-
1
-
- -
-
-
-
-
- Response 200 OK - -
+
+ + + +
Example URI
+ https://owner-api.teslamotors.com +
Headers
+
    +
  • + + Authorization: Bearer {access_token} + +
  • +
+ +
URI Parameters
+
+ + + + + + + + + + + + +
keytypestatusdescriptionvalue
vehicle_idstring requiredThe id of the Vehicle.1
+
+
-
-
Headers
-
    -
  • - Content-Type: application/json - -
  • -
-
-
- - application/json -
-
{
-  "response": {
-    "result": true,
-    "reason": ""
+                
+ +
+
+
+ Response 200 OK + +
+
+
+
Headers
+
    +
  • + + Content-Type: application/json + +
  • +
+
+
+ application/json +
+
{
+  "response": {
+    "result": true,
+    "reason": ""
   }
 }
 
-
-
-
-
-
-

- - Lock Doors - /api/1/vehicles/{vehicle_id}/command/door_lock -

-
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
-
-
-
-
- POST - /api/1/vehicles/{vehicle_id}/command/door_lock - - Lock Doors -
+
-
-

Lock the car's doors. -

-
-
-
Request - -
-
+
+
+
+

+ + Lock Doors + + /api/1/vehicles/{vehicle_id}/command/door_lock +

+
+
+
+ POST + /api/1/vehicles/{vehicle_id}/command/door_lock + + Lock Doors + +
+
+
+

Lock the car's doors.

+
+
+
+ Request +
+
-
- - - -
Example URI
- https://owner-api.teslamotors.com/api/1/vehicles/1/command/door_lock -
Headers
-
    -
  • - Authorization: Bearer {access_token} - -
  • -
- -
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
vehicle_idstring required

The id of the Vehicle.

-
1
-
- -
-
-
-
-
- Response 200 OK - -
+
+ + + +
Example URI
+ https://owner-api.teslamotors.com +
Headers
+
    +
  • + + Authorization: Bearer {access_token} + +
  • +
+ +
URI Parameters
+
+ + + + + + + + + + + + +
keytypestatusdescriptionvalue
vehicle_idstring requiredThe id of the Vehicle.1
+
+
-
-
Headers
-
    -
  • - Content-Type: application/json - -
  • -
-
-
- - application/json -
-
{
-  "response": {
-    "result": true,
-    "reason": ""
+                
+ +
+
+
+ Response 200 OK + +
+
+
+
Headers
+
    +
  • + + Content-Type: application/json + +
  • +
+
+
+ application/json +
+
{
+  "response": {
+    "result": true,
+    "reason": ""
   }
 }
 
-
-
-
-
-
-

- - Set Temperature - /api/1/vehicles/{vehicle_id}/command/set_temps?driver_temp={driver_degC}&passenger_temp={pass_degC} -

-
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
-
-
-
-
- POST - /api/1/vehicles/{vehicle_id}/command/set_temps?driver_temp={driver_degC}&passenger_temp={pass_degC} - - Set Temperature -
+
-
-

Set the temperature target for the HVAC system. -

-
-
-
Request - -
-
+
+
+
+

+ + Set Temperature + + /api/1/vehicles/{vehicle_id}/command/set_temps?driver_temp={driver_degC}&passenger_temp={pass_degC} +

+
+
+
+ POST + /api/1/vehicles/{vehicle_id}/command/set_temps?driver_temp={driver_degC}&passenger_temp={pass_degC} + + Set Temperature + +
+
+
+

Set the temperature target for the HVAC system.

+
+
+
+ Request +
+
-
- - - -
Example URI
- https://owner-api.teslamotors.com/api/1/vehicles/1/command/set_temps?driver_temp=23.7&passenger_temp=18.1 -
Headers
-
    -
  • - Authorization: Bearer {access_token} - -
  • -
- -
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
vehicle_idstring required

The id of the Vehicle.

-
1
driver_degCstring required

The desired temperature on the driver's side in °C.

-
23.7
pass_degCstring required

The desired temperature on the passenger's side in °C.

-
18.1
-
- -
-
-
-
-
- Response 200 OK - -
+
+ + + +
Example URI
+ https://owner-api.teslamotors.com +
Headers
+
    +
  • + + Authorization: Bearer {access_token} + +
  • +
+ +
URI Parameters
+
+ + + + + + + + + + + + +
keytypestatusdescriptionvalue
vehicle_idstring requiredThe id of the Vehicle.1
driver_degCstring requiredThe desired temperature on the driver's side in °C.23.7
pass_degCstring requiredThe desired temperature on the passenger's side in °C.18.1
+
+
-
-
Headers
-
    -
  • - Content-Type: application/json - -
  • -
-
-
- - application/json -
-
{
-  "response": {
-    "result": true,
-    "reason": ""
+                
+ +
+
+
+ Response 200 OK + +
+
+
+
Headers
+
    +
  • + + Content-Type: application/json + +
  • +
+
+
+ application/json +
+
{
+  "response": {
+    "result": true,
+    "reason": ""
   }
 }
 
-
-
-
-
-
-

- - Start HVAC System - /api/1/vehicles/{vehicle_id}/command/auto_conditioning_start -

-
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
-
-
-
-
- POST - /api/1/vehicles/{vehicle_id}/command/auto_conditioning_start - - Start HVAC System -
+
-
-

Start the climate control system. Will cool or heat automatically, depending on set temperature. -

-
-
-
Request - -
-
+
+
+
+

+ + Start HVAC System + + /api/1/vehicles/{vehicle_id}/command/auto_conditioning_start +

+
+
+
+ POST + /api/1/vehicles/{vehicle_id}/command/auto_conditioning_start + + Start HVAC System + +
+
+
+

Start the climate control system. Will cool or heat automatically, depending on set temperature.

+
+
+
+ Request +
+
-
- - - -
Example URI
- https://owner-api.teslamotors.com/api/1/vehicles/1/command/auto_conditioning_start -
Headers
-
    -
  • - Authorization: Bearer {access_token} - -
  • -
- -
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
vehicle_idstring required

The id of the Vehicle.

-
1
-
- -
-
-
-
-
- Response 200 OK - -
+
+ + + +
Example URI
+ https://owner-api.teslamotors.com +
Headers
+
    +
  • + + Authorization: Bearer {access_token} + +
  • +
+ +
URI Parameters
+
+ + + + + + + + + + + + +
keytypestatusdescriptionvalue
vehicle_idstring requiredThe id of the Vehicle.1
+
+
-
-
Headers
-
    -
  • - Content-Type: application/json - -
  • -
-
-
- - application/json -
-
{
-  "response": {
-    "result": true,
-    "reason": ""
+                
+ +
+
+
+ Response 200 OK + +
+
+
+
Headers
+
    +
  • + + Content-Type: application/json + +
  • +
+
+
+ application/json +
+
{
+  "response": {
+    "result": true,
+    "reason": ""
   }
 }
 
-
-
-
-
-
-

- - Stop HVAC System - /api/1/vehicles/{vehicle_id}/command/auto_conditioning_stop -

-
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
-
-
-
-
- POST - /api/1/vehicles/{vehicle_id}/command/auto_conditioning_stop - - Stop HVAC System -
+
-
-

Stop the climate control system. -

-
-
-
Request - -
-
+
+
+
+

+ + Stop HVAC System + + /api/1/vehicles/{vehicle_id}/command/auto_conditioning_stop +

+
+
+
+ POST + /api/1/vehicles/{vehicle_id}/command/auto_conditioning_stop + + Stop HVAC System + +
+
+
+

Stop the climate control system.

+
+
+
+ Request +
+
-
- - - -
Example URI
- https://owner-api.teslamotors.com/api/1/vehicles/1/command/auto_conditioning_stop -
Headers
-
    -
  • - Authorization: Bearer {access_token} - -
  • -
- -
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
vehicle_idstring required

The id of the Vehicle.

-
1
-
- -
-
-
-
-
- Response 200 OK - -
+
+ + + +
Example URI
+ https://owner-api.teslamotors.com +
Headers
+
    +
  • + + Authorization: Bearer {access_token} + +
  • +
+ +
URI Parameters
+
+ + + + + + + + + + + + +
keytypestatusdescriptionvalue
vehicle_idstring requiredThe id of the Vehicle.1
+
+
-
-
Headers
-
    -
  • - Content-Type: application/json - -
  • -
-
-
- - application/json -
-
{
-  "response": {
-    "result": true,
-    "reason": ""
+                
+ +
+
+
+ Response 200 OK + +
+
+
+
Headers
+
    +
  • + + Content-Type: application/json + +
  • +
+
+
+ application/json +
+
{
+  "response": {
+    "result": true,
+    "reason": ""
   }
 }
 
-
-
-
-
-
-

- - Move Pano Roof - /api/1/vehicles/{vehicle_id}/command/sun_roof_control?state={state}&percent={percent} -

-
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
-
-
-
-
- POST - /api/1/vehicles/{vehicle_id}/command/sun_roof_control?state={state}&percent={percent} - - Move Pano Roof -
+
-
-

Controls the car's panoramic roof, if installed. -

-
-
-
Request - -
-
+
+
+
+

+ + Move Pano Roof + + /api/1/vehicles/{vehicle_id}/command/sun_roof_control?state={state}&percent={percent} +

+
+
+
+ POST + /api/1/vehicles/{vehicle_id}/command/sun_roof_control?state={state}&percent={percent} + + Move Pano Roof + +
+
+
+

Controls the car's panoramic roof, if installed.

+
+
+
+ Request +
+
-
- - - -
Example URI
- https://owner-api.teslamotors.com/api/1/vehicles/1/command/sun_roof_control?state=open&percent=50 -
Headers
-
    -
  • - Authorization: Bearer {access_token} - -
  • -
- -
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
vehicle_idstring required

The id of the Vehicle.

-
1
stateenum required

The desired state of the panoramic roof. The approximate percent open values for each state are open = 100%, close = 0%, comfort = 80%, and vent = ~15%

-
openenum
percentstring optional

The percentage to move the roof to.

-
50
-
- -
-
-
-
-
- Response 200 OK - -
+
+ + + +
Example URI
+ https://owner-api.teslamotors.com +
Headers
+
    +
  • + + Authorization: Bearer {access_token} + +
  • +
+ +
URI Parameters
+
+ + + + + + + + + + + + +
keytypestatusdescriptionvalue
vehicle_idstring requiredThe id of the Vehicle.1
stateenum required +The desired state of the panoramic roof. The approximate percent open values for each state are `open` = 100%, `close` = 0%, `comfort` = 80%, and `vent` = ~15% +
openenum
percentstring optionalThe percentage to move the roof to.50
+
+
-
-
Headers
-
    -
  • - Content-Type: application/json - -
  • -
-
-
- - application/json -
-
{
-  "response": {
-    "result": true,
-    "reason": ""
+                
+ +
+
+
+ Response 200 OK + +
+
+
+
Headers
+
    +
  • + + Content-Type: application/json + +
  • +
+
+
+ application/json +
+
{
+  "response": {
+    "result": true,
+    "reason": ""
   }
 }
 
-
-
-
-
-
-

- - Remote Start - /api/1/vehicles/{vehicle_id}/command/remote_start_drive?password={password} -

-
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
-
-
-
-
- POST - /api/1/vehicles/{vehicle_id}/command/remote_start_drive?password={password} - - Remote Start -
+
-
-

Start the car for keyless driving. Must start driving within 2 minutes of issuing this request. -

-
-
-
Request - -
-
+
+
+
+

+ + Remote Start + + /api/1/vehicles/{vehicle_id}/command/remote_start_drive?password={password} +

+
+
+
+ POST + /api/1/vehicles/{vehicle_id}/command/remote_start_drive?password={password} + + Remote Start + +
+
+
+

Start the car for keyless driving. Must start driving within 2 minutes of issuing this request.

+
+
+
+ Request +
+
-
- - - -
Example URI
- https://owner-api.teslamotors.com/api/1/vehicles/1/command/remote_start_drive?password=edisonsux -
Headers
-
    -
  • - Authorization: Bearer {access_token} - -
  • -
- -
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
vehicle_idstring required

The id of the Vehicle.

-
1
passwordstring required

The password to the authenticated my.teslamotors.com account.

-
edisonsux
-
- -
-
-
-
-
- Response 200 OK - -
+
+ + + +
Example URI
+ https://owner-api.teslamotors.com +
Headers
+
    +
  • + + Authorization: Bearer {access_token} + +
  • +
+ +
URI Parameters
+
+ + + + + + + + + + + + +
keytypestatusdescriptionvalue
vehicle_idstring requiredThe id of the Vehicle.1
passwordstring requiredThe password to the authenticated my.teslamotors.com account.edisonsux
+
+
-
-
Headers
-
    -
  • - Content-Type: application/json - -
  • -
-
-
- - application/json -
-
{
-  "response": {
-    "result": true,
-    "reason": ""
+                
+ +
+
+
+ Response 200 OK + +
+
+
+
Headers
+
    +
  • + + Content-Type: application/json + +
  • +
+
+
+ application/json +
+
{
+  "response": {
+    "result": true,
+    "reason": ""
   }
 }
 
-
-
-
-
-
-

- - Open Trunk/Frunk - /api/1/vehicles/{vehicle_id}/command/trunk_open -

-
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
-
-
-
-
- POST - /api/1/vehicles/{vehicle_id}/command/trunk_open - - Open Trunk/Frunk -
+
-
-

Open the trunk or frunk. Currently inoperable. -

-
-
-
Request - -
-
+
+
+
+

+ + Open Trunk/Frunk + + /api/1/vehicles/{vehicle_id}/command/trunk_open +

+
+
+
+ POST + /api/1/vehicles/{vehicle_id}/command/trunk_open + + Open Trunk/Frunk + +
+
+
+

Open the trunk or frunk. Currently inoperable.

+
+
+
+ Request +
+
-
- - - -
Example URI
- https://owner-api.teslamotors.com/api/1/vehicles/1/command/trunk_open -
Headers
-
    -
  • - Authorization: Bearer {access_token} - -
  • -
- -
URI Parameters
-
- - - - -
keytypestatusdescriptionvalue
vehicle_idstring required

The id of the Vehicle.

-
1
-
- -
Request object
-
-
which_trunkstring

The trunk to open. rear is the only one known currently.

-
rear
-
-
-
-
-
- Response 200 OK - -
+
+ + + +
Example URI
+ https://owner-api.teslamotors.com +
Headers
+
    +
  • + + Authorization: Bearer {access_token} + +
  • +
+ +
URI Parameters
+
+ + + + + + + + + + + + +
keytypestatusdescriptionvalue
vehicle_idstring requiredThe id of the Vehicle.1
+
+ +
Request object
+
+
which_trunkstring The trunk to open. `rear` is the only one known currently.rear
+
-
-
Headers
-
    -
  • - Content-Type: application/json - -
  • -
-
-
- - application/json -
-
{
-  "response": {
-    "result": true,
-    "reason": ""
+                
+ +
+
+
+ Response 200 OK + +
+
+
+
Headers
+
    +
  • + + Content-Type: application/json + +
  • +
+
+
+ application/json +
+
{
+  "response": {
+    "result": true,
+    "reason": ""
   }
 }
 
-
-
-
-
-
-
+
+
+ + +
diff --git a/tests/statics/drafter/html/material.html b/tests/statics/drafter/html/material.html index d447abfb..f5eaf57a 100644 --- a/tests/statics/drafter/html/material.html +++ b/tests/statics/drafter/html/material.html @@ -2,2644 +2,3483 @@ Tesla Model S JSON API - - - - + + + + + + -
-
-
- - Tesla Model S JSON API -
-
-
-
- + + + https://owner-api.teslamotors.com +
+
+

Authentication

+
+

+ + Tokens + + /oauth/token +

+
+
+
+ POST + /oauth/token + + Get an Access Token + +
-
-
-

Authentication

-

- Tokens - /oauth/token -

-
-
-

POST - /oauth/token - Get an Access Token

-
-
- Performs the login. Takes in an plain text email and password, matching the owner's login information for https://my.teslamotors.com/user/login. +
+

Performs the login. Takes in an plain text email and password, matching the owner's login information for https://my.teslamotors.com/user/login.

Returns a access_token which is passed along as a header with all future requests to authenticate the user.

You must provide the Authorization: Bearer {access_token} header in all other requests.

The current client ID and secret are available here

-
- - -

CURL Command

-
- This might be useful for debugging -
- +
    +
  • +
    +
    + filter_dramaRequest
    +
    +
    + + +
    Example URI
    + https://owner-api.teslamotors.com + + +
    Request object
    +
    +
    grant_typestring The type of oAuth grant. Always "password"password
    client_idstring The oAuth client IDabc
    client_secretstring The oAuth client secret123
    emailstring The email for my.teslamotors.comelon@teslamotors.com
    passwordstring The password for my.teslamotors.comedisonsux
    +
    -
-
- -
-
-
-
Example URI
- https://owner-api.teslamotors.com - /oauth/token -
Request object
-
grant_typestring

The type of oAuth grant. Always "password"

-
password
client_idstring

The oAuth client ID

-
abc
client_secretstring

The oAuth client secret

-
123
emailstring

The email for my.teslamotors.com

-
elon@teslamotors.com
passwordstring

The password for my.teslamotors.com

-
edisonsux
-
-
Headers
-
    -
  • - - Content-Type: application/json - -
  • -
-
-
-
application/json
-
{
-  "access_token": "abc123",
-  "token_type": "bearer",
-  "expires_in": 7776000,
-  "created_at": 1457385291
+                    
+                            
+                                                
  • +
    + publishResponse 200 OK +
    +
    +
    +
    Headers
    +
      +
    • + + Content-Type: application/json + +
    • +
    +
    +
    + application/json +
    +
    {
    +  "access_token": "abc123",
    +  "token_type": "bearer",
    +  "expires_in": 7776000,
    +  "created_at": 1457385291
     }
     
    -
    -
    -
    - -
  • -
    +
    +
    -

    Vehicles

    -

    A logged in user can have multiple vehicles under their account. This resource is primarily responsible for listing the vehicles and the basic details about them. + + +

    +
    +

    Vehicles

    +

    A logged in user can have multiple vehicles under their account. This resource is primarily responsible for listing the vehicles and the basic details about them.

    -

    - Vehicle Collection - /api/1/vehicles -

    -
    -
    -

    GET - /api/1/vehicles - List all Vehicles

    +
    +

    + + Vehicle Collection + + /api/1/vehicles +

    +
    +
    +
    + GET + /api/1/vehicles + + List all Vehicles + +
    +
    +
    +

    Retrieve a list of your owned vehicles (includes vehicles not yet shipped!)

    +
      +
    • +
      +
      + filter_dramaRequest
      +
      +
      + + -
      - Retrieve a list of your owned vehicles (includes vehicles not yet shipped!) -
      - - -

      CURL Command

      -
      - This might be useful for debugging -
      - +
      Example URI
      + https://owner-api.teslamotors.com +
      Headers
      +
        +
      • + + Authorization: Bearer {access_token} + +
      • +
      + +
      -
      -
      - -
      -
      -
      -
      Example URI
      - https://owner-api.teslamotors.com - /api/1/vehicles +
    • + +
    • +
      + publishResponse 200 OK +
      +
      +
      Headers
      -
        -
      • - - Authorization: Bearer {access_token} - -
      • -
      -
      -
      -
      Headers
      -
        -
      • - - Content-Type: application/json - -
      • -
      -
      -
      -
      application/json
      -
      {
      -  "response": [{
      -    "color": null,
      -    "display_name": null,
      -    "id": 321,
      -    "option_codes": "MS01,RENA,TM00,DRLH,PF00,BT85,PBCW,RFPO,WT19,IBMB,IDPB,TR00,SU01,SC01,TP01,AU01,CH00,HP00,PA00,PS00,AD02,X020,X025,X001,X003,X007,X011,X013",
      -    "user_id": 123,
      -    "vehicle_id": 1234567890,
      -    "vin": "5YJSA1CN5CFP01657",
      -    "tokens": ["x", "x"],
      -    "state": "online"
      +                                    
        +
      • + + Content-Type: application/json + +
      • +
      +
      +
      + application/json +
      +
      {
      +  "response": [{
      +    "color": null,
      +    "display_name": null,
      +    "id": 321,
      +    "option_codes": "MS01,RENA,TM00,DRLH,PF00,BT85,PBCW,RFPO,WT19,IBMB,IDPB,TR00,SU01,SC01,TP01,AU01,CH00,HP00,PA00,PS00,AD02,X020,X025,X001,X003,X007,X011,X013",
      +    "user_id": 123,
      +    "vehicle_id": 1234567890,
      +    "vin": "5YJSA1CN5CFP01657",
      +    "tokens": ["x", "x"],
      +    "state": "online"
         }],
      -  "count":1
      +  "count":1
       }
       
      -
      -
      -
      +
      +
      +
    + + +
    +
    +

    + + State and Settings + + /api/1/vehicles/{vehicle_id} +

    +

    These resources are read-only and determine the state of the vehicle's various sub-systems.

    -
    -
    +
    URI Parameters
    +
    + + + + +
    keytypestatusdescriptionvalue
    vehicle_idstring requiredThe id of the Vehicle.1
    +
    +
    +
    +
    + GET + /api/1/vehicles/{vehicle_id}/mobile_enabled + + Mobile Access + +
    +
    +
    +

    Determines if mobile access to the vehicle is enabled.

    +
      +
    • +
      +
      + filter_dramaRequest
      -

      - State and Settings - /api/1/vehicles/{vehicle_id} -

      -

      These resources are read-only and determine the state of the vehicle's various sub-systems. -

      -
      -
      -

      GET - /api/1/vehicles/{vehicle_id}/mobile_enabled - Mobile Access

      +
      + + -
      - Determines if mobile access to the vehicle is enabled. -
      - - -

      CURL Command

      -
      - This might be useful for debugging -
      - +
      Example URI
      + https://owner-api.teslamotors.com +
      Headers
      +
        +
      • + + Authorization: Bearer {access_token} + +
      • +
      + +
      URI Parameters
      +
      + + + + + + + + + + + + +
      keytypestatusdescriptionvalue
      vehicle_idstring requiredThe id of the Vehicle.1
      +
      +
      -
      -
      - -
      -
      -
      -
      Example URI
      - https://owner-api.teslamotors.com - /api/1/vehicles/1/mobile_enabled +
    • + +
    • +
      + publishResponse 200 OK +
      +
      +
      Headers
      -
        -
      • - - Authorization: Bearer {access_token} - -
      • -
      -
      URI Parameters
      - - - - -
      KeyTypeStatusDescriptionValue
      vehicle_idstring required

      The id of the Vehicle.

      -
      1
      -
      -
      -
      Headers
      -
        -
      • - - Content-Type: application/json - -
      • -
      -
      -
      -
      application/json
      -
      {
      -    "response": true
      +                                    
        +
      • + + Content-Type: application/json + +
      • +
      +
      +
      + application/json +
      +
      {
      +    "response": true
       }
       
      -
      -
      -
      - -
      -
      +
    + -
    -
    -

    GET - /api/1/vehicles/{vehicle_id}/data_request/charge_state - Charge State

    + + +
    +
    +
    +
    + GET + /api/1/vehicles/{vehicle_id}/data_request/charge_state + + Charge State + +
    +
    +
    +

    Returns the state of charge in the battery.

    +
      +
    • +
      +
      + filter_dramaRequest
      +
      +
      + + -
      - Returns the state of charge in the battery. -
      - - -

      CURL Command

      -
      - This might be useful for debugging -
      - +
      Example URI
      + https://owner-api.teslamotors.com +
      Headers
      +
        +
      • + + Authorization: Bearer {access_token} + +
      • +
      + +
      URI Parameters
      +
      + + + + + + + + + + + + +
      keytypestatusdescriptionvalue
      vehicle_idstring requiredThe id of the Vehicle.1
      +
      +
      -
      -
      - -
      -
      -
      -
      Example URI
      - https://owner-api.teslamotors.com - /api/1/vehicles/1/data_request/charge_state +
    • + +
    • +
      + publishResponse 200 OK +
      +
      +
      Headers
      -
        -
      • - - Authorization: Bearer {access_token} - -
      • -
      -
      URI Parameters
      - - - - -
      KeyTypeStatusDescriptionValue
      vehicle_idstring required

      The id of the Vehicle.

      -
      1
      -
      -
      -
      Headers
      -
        -
      • - - Content-Type: application/json - -
      • -
      -
      -
      -
      application/json
      -
      {
      -  "response": {
      -    "charging_state": "Complete",  // "Charging", ??
      -    "charge_to_max_range": false,  // current std/max-range setting
      -    "max_range_charge_counter": 0,
      -    "fast_charger_present": false, // connected to Supercharger?
      -    "battery_range": 239.02,       // rated miles
      -    "est_battery_range": 155.79,   // range estimated from recent driving
      -    "ideal_battery_range": 275.09, // ideal miles
      -    "battery_level": 91,           // integer charge percentage
      -    "battery_current": -0.6,       // current flowing into battery
      -    "charge_starting_range": null,
      -    "charge_starting_soc": null,
      -    "charger_voltage": 0,          // only has value while charging
      -    "charger_pilot_current": 40,   // max current allowed by charger & adapter
      -    "charger_actual_current": 0,   // current actually being drawn
      -    "charger_power": 0,            // kW (rounded down) of charger
      -    "time_to_full_charge": null,   // valid only while charging
      -    "charge_rate": -1.0,           // float mi/hr charging or -1 if not charging
      -    "charge_port_door_open": true
      +                                    
        +
      • + + Content-Type: application/json + +
      • +
      +
      +
      + application/json +
      +
      {
      +  "response": {
      +    "charging_state": "Complete",  // "Charging", ??
      +    "charge_to_max_range": false,  // current std/max-range setting
      +    "max_range_charge_counter": 0,
      +    "fast_charger_present": false, // connected to Supercharger?
      +    "battery_range": 239.02,       // rated miles
      +    "est_battery_range": 155.79,   // range estimated from recent driving
      +    "ideal_battery_range": 275.09, // ideal miles
      +    "battery_level": 91,           // integer charge percentage
      +    "battery_current": -0.6,       // current flowing into battery
      +    "charge_starting_range": null,
      +    "charge_starting_soc": null,
      +    "charger_voltage": 0,          // only has value while charging
      +    "charger_pilot_current": 40,   // max current allowed by charger & adapter
      +    "charger_actual_current": 0,   // current actually being drawn
      +    "charger_power": 0,            // kW (rounded down) of charger
      +    "time_to_full_charge": null,   // valid only while charging
      +    "charge_rate": -1.0,           // float mi/hr charging or -1 if not charging
      +    "charge_port_door_open": true
         }
       }
       
      -
      -
      -
      - -
      -
      +
    + + + + + +
    +
    +
    + GET + /api/1/vehicles/{vehicle_id}/data_request/climate_state + + Climate Settings + +
    +
    +
    +

    Returns the current temperature and climate control state.

    +
      +
    • +
      +
      + filter_dramaRequest
      -
      -
      -

      GET - /api/1/vehicles/{vehicle_id}/data_request/climate_state - Climate Settings

      +
      + + -
      - Returns the current temperature and climate control state. -
      - - -

      CURL Command

      -
      - This might be useful for debugging -
      - +
      Example URI
      + https://owner-api.teslamotors.com +
      Headers
      +
        +
      • + + Authorization: Bearer {access_token} + +
      • +
      + +
      URI Parameters
      +
      + + + + + + + + + + + + +
      keytypestatusdescriptionvalue
      vehicle_idstring requiredThe id of the Vehicle.1
      +
      +
      -
      -
      - -
      -
      -
      -
      Example URI
      - https://owner-api.teslamotors.com - /api/1/vehicles/1/data_request/climate_state +
    • + +
    • +
      + publishResponse 200 OK +
      +
      +
      Headers
      -
        -
      • - - Authorization: Bearer {access_token} - -
      • -
      -
      URI Parameters
      - - - - -
      KeyTypeStatusDescriptionValue
      vehicle_idstring required

      The id of the Vehicle.

      -
      1
      -
      -
      -
      Headers
      -
        -
      • - - Content-Type: application/json - -
      • -
      -
      -
      -
      application/json
      -
      {
      -  "response": {
      -    "inside_temp": 17.0,          // degC inside car
      -    "outside_temp": 9.5,          // degC outside car or null
      -    "driver_temp_setting": 22.6,  // degC of driver temperature setpoint
      -    "passenger_temp_setting": 22.6, // degC of passenger temperature setpoint
      -    "is_auto_conditioning_on": false, // apparently even if on
      -    "is_front_defroster_on": null, // null or boolean as integer?
      -    "is_rear_defroster_on": false,
      -    "fan_status": 0               // fan speed 0-6 or null
      +                                    
        +
      • + + Content-Type: application/json + +
      • +
      +
      +
      + application/json +
      +
      {
      +  "response": {
      +    "inside_temp": 17.0,          // degC inside car
      +    "outside_temp": 9.5,          // degC outside car or null
      +    "driver_temp_setting": 22.6,  // degC of driver temperature setpoint
      +    "passenger_temp_setting": 22.6, // degC of passenger temperature setpoint
      +    "is_auto_conditioning_on": false, // apparently even if on
      +    "is_front_defroster_on": null, // null or boolean as integer?
      +    "is_rear_defroster_on": false,
      +    "fan_status": 0               // fan speed 0-6 or null
         }
       }
       
      -
      -
      -
      - -
      -
      +
    + -
    -
    -

    GET - /api/1/vehicles/{vehicle_id}/data_request/drive_state - Driving and Position

    + + +
    +
    +
    +
    + GET + /api/1/vehicles/{vehicle_id}/data_request/drive_state + + Driving and Position + +
    +
    +
    +

    Returns the driving and position state of the vehicle.

    +
      +
    • +
      +
      + filter_dramaRequest
      +
      +
      + + -
      - Returns the driving and position state of the vehicle. -
      - - -

      CURL Command

      -
      - This might be useful for debugging -
      - +
      Example URI
      + https://owner-api.teslamotors.com +
      Headers
      +
        +
      • + + Authorization: Bearer {access_token} + +
      • +
      + +
      URI Parameters
      +
      + + + + + + + + + + + + +
      keytypestatusdescriptionvalue
      vehicle_idstring requiredThe id of the Vehicle.1
      +
      +
      -
      -
      - -
      -
      -
      -
      Example URI
      - https://owner-api.teslamotors.com - /api/1/vehicles/1/data_request/drive_state +
    • + +
    • +
      + publishResponse 200 OK +
      +
      +
      Headers
      -
        -
      • - - Authorization: Bearer {access_token} - -
      • -
      -
      URI Parameters
      - - - - -
      KeyTypeStatusDescriptionValue
      vehicle_idstring required

      The id of the Vehicle.

      -
      1
      -
      -
      -
      Headers
      -
        -
      • - - Content-Type: application/json - -
      • -
      -
      -
      -
      application/json
      -
      {
      -  "response": {
      -    "shift_state": null,          //
      -    "speed": null,                //
      -    "latitude": 33.794839,        // degrees N of equator
      -    "longitude": -84.401593,      // degrees W of the prime meridian
      -    "heading": 4,                 // integer compass heading, 0-359
      -    "gps_as_of": 1359863204       // Unix timestamp of GPS fix
      +                                    
        +
      • + + Content-Type: application/json + +
      • +
      +
      +
      + application/json +
      +
      {
      +  "response": {
      +    "shift_state": null,          //
      +    "speed": null,                //
      +    "latitude": 33.794839,        // degrees N of equator
      +    "longitude": -84.401593,      // degrees W of the prime meridian
      +    "heading": 4,                 // integer compass heading, 0-359
      +    "gps_as_of": 1359863204       // Unix timestamp of GPS fix
         }
       }
       
      -
      -
      -
      - -
      -
      +
    + -
    -
    -

    GET - /api/1/vehicles/{vehicle_id}/data_request/gui_settings - GUI Settings

    + + +
    +
    +
    +
    + GET + /api/1/vehicles/{vehicle_id}/data_request/gui_settings + + GUI Settings + +
    +
    +
    +

    Returns various information about the GUI settings of the car, such as unit format and range display.

    +
      +
    • +
      +
      + filter_dramaRequest
      +
      +
      + + -
      - Returns various information about the GUI settings of the car, such as unit format and range display. -
      - - -

      CURL Command

      -
      - This might be useful for debugging -
      - +
      Example URI
      + https://owner-api.teslamotors.com +
      Headers
      +
        +
      • + + Authorization: Bearer {access_token} + +
      • +
      + +
      URI Parameters
      +
      + + + + + + + + + + + + +
      keytypestatusdescriptionvalue
      vehicle_idstring requiredThe id of the Vehicle.1
      +
      +
      -
      -
      - -
      -
      -
      -
      Example URI
      - https://owner-api.teslamotors.com - /api/1/vehicles/1/data_request/gui_settings +
    • + +
    • +
      + publishResponse 200 OK +
      +
      +
      Headers
      -
        -
      • - - Authorization: Bearer {access_token} - -
      • -
      -
      URI Parameters
      - - - - -
      KeyTypeStatusDescriptionValue
      vehicle_idstring required

      The id of the Vehicle.

      -
      1
      -
      -
      -
      Headers
      -
        -
      • - - Content-Type: application/json - -
      • -
      -
      -
      -
      application/json
      -
      {
      -  "response": {
      -    "gui_distance_units": "mi/hr",
      -    "gui_temperature_units": "F",
      -    "gui_charge_rate_units": "mi/hr",
      -    "gui_24_hour_time": false,
      -    "gui_range_display": "Rated"
      +                                    
        +
      • + + Content-Type: application/json + +
      • +
      +
      +
      + application/json +
      +
      {
      +  "response": {
      +    "gui_distance_units": "mi/hr",
      +    "gui_temperature_units": "F",
      +    "gui_charge_rate_units": "mi/hr",
      +    "gui_24_hour_time": false,
      +    "gui_range_display": "Rated"
         }
       }
       
      -
      -
      -
      - -
      -
      +
    + -
    -
    -

    GET - /api/1/vehicles/{vehicle_id}/data_request/vehicle_state - Vehicle State

    + + +
    +
    +
    +
    + GET + /api/1/vehicles/{vehicle_id}/data_request/vehicle_state + + Vehicle State + +
    +
    +
    +

    Returns the vehicle's physical state, such as which doors are open.

    +
      +
    • +
      +
      + filter_dramaRequest
      +
      +
      + + -
      - Returns the vehicle's physical state, such as which doors are open. -
      - - -

      CURL Command

      -
      - This might be useful for debugging -
      - +
      Example URI
      + https://owner-api.teslamotors.com +
      Headers
      +
        +
      • + + Authorization: Bearer {access_token} + +
      • +
      + +
      URI Parameters
      +
      + + + + + + + + + + + + +
      keytypestatusdescriptionvalue
      vehicle_idstring requiredThe id of the Vehicle.1
      +
      +
      -
      -
      - -
      -
      -
      -
      Example URI
      - https://owner-api.teslamotors.com - /api/1/vehicles/1/data_request/vehicle_state +
    • + +
    • +
      + publishResponse 200 OK +
      +
      +
      Headers
      -
        -
      • - - Authorization: Bearer {access_token} - -
      • -
      -
      URI Parameters
      - - - - -
      KeyTypeStatusDescriptionValue
      vehicle_idstring required

      The id of the Vehicle.

      -
      1
      -
      -
      -
      Headers
      -
        -
      • - - Content-Type: application/json - -
      • -
      -
      -
      -
      application/json
      -
      {
      -  "response": {
      -    "df": false,                  // driver's side front door open
      -    "dr": false,                  // driver's side rear door open
      -    "pf": false,                  // passenger's side front door open
      -    "pr": false,                  // passenger's side rear door open
      -    "ft": false,                  // front trunk is open
      -    "rt": false,                  // rear trunk is open
      -    "car_verson": "1.19.42",      // car firmware version
      -    "locked": true,               // car is locked
      -    "sun_roof_installed": false,  // panoramic roof is installed
      -    "sun_roof_state": "unknown",
      -    "sun_roof_percent_open": 0,   // null if not installed
      -    "dark_rims": false,           // gray rims installed
      -    "wheel_type": "Base19",       // wheel type installed
      -    "has_spoiler": false,         // spoiler is installed
      -    "roof_color": "Colored",      // "None" for panoramic roof
      -    "perf_config": "Base"
      +                                    
        +
      • + + Content-Type: application/json + +
      • +
      +
      +
      + application/json +
      +
      {
      +  "response": {
      +    "df": false,                  // driver's side front door open
      +    "dr": false,                  // driver's side rear door open
      +    "pf": false,                  // passenger's side front door open
      +    "pr": false,                  // passenger's side rear door open
      +    "ft": false,                  // front trunk is open
      +    "rt": false,                  // rear trunk is open
      +    "car_verson": "1.19.42",      // car firmware version
      +    "locked": true,               // car is locked
      +    "sun_roof_installed": false,  // panoramic roof is installed
      +    "sun_roof_state": "unknown",
      +    "sun_roof_percent_open": 0,   // null if not installed
      +    "dark_rims": false,           // gray rims installed
      +    "wheel_type": "Base19",       // wheel type installed
      +    "has_spoiler": false,         // spoiler is installed
      +    "roof_color": "Colored",      // "None" for panoramic roof
      +    "perf_config": "Base"
         }
       }
       
      -
      -
      -
      - -
      -
      +
    + -

    Vehicle Commands

    -

    These commands alter the vehicles state, and return result (true/false) to indicate success, and if failure reason contains the cause of failure. + + + +

    +

    Vehicle Commands

    +

    These commands alter the vehicles state, and return result (true/false) to indicate success, and if failure reason contains the cause of failure.

    -

    - Wake Up Car - /api/1/vehicles/{vehicle_id}/wake_up -

    -
    -
    -

    POST - /api/1/vehicles/{vehicle_id}/wake_up - Wake Up Car

    +
    +

    + + Wake Up Car + + /api/1/vehicles/{vehicle_id}/wake_up +

    +
    +
    +
    + POST + /api/1/vehicles/{vehicle_id}/wake_up + + Wake Up Car + +
    +
    +
    +

    Wakes up the car from the sleep state. Necessary to get some data from the car.

    +
      +
    • +
      +
      + filter_dramaRequest
      +
      +
      + + -
      - Wakes up the car from the sleep state. Necessary to get some data from the car. -
      - - -

      CURL Command

      -
      - This might be useful for debugging -
      - +
      Example URI
      + https://owner-api.teslamotors.com +
      Headers
      +
        +
      • + + Authorization: Bearer {access_token} + +
      • +
      + +
      URI Parameters
      +
      + + + + + + + + + + + + +
      keytypestatusdescriptionvalue
      vehicle_idstring requiredThe id of the Vehicle.1
      +
      +
      -
      -
      - -
      -
      -
      -
      Example URI
      - https://owner-api.teslamotors.com - /api/1/vehicles/1/wake_up +
    • + +
    • +
      + publishResponse 200 OK +
      +
      +
      Headers
      -
        -
      • - - Authorization: Bearer {access_token} - -
      • -
      -
      URI Parameters
      - - - - -
      KeyTypeStatusDescriptionValue
      vehicle_idstring required

      The id of the Vehicle.

      -
      1
      -
      -
      -
      Headers
      -
        -
      • - - Content-Type: application/json - -
      • -
      -
      -
      -
      application/json
      -
      {
      -  "response": {
      -    "result": true,
      -    "reason": ""
      +                                    
        +
      • + + Content-Type: application/json + +
      • +
      +
      +
      + application/json +
      +
      {
      +  "response": {
      +    "result": true,
      +    "reason": ""
         }
       }
       
      -
      -
      -
      - -
      -
      +
    +
    -

    - Set Valet Mode - /api/1/vehicles/{vehicle_id}/command/set_valet_mode -

    -
    -
    -

    POST - /api/1/vehicles/{vehicle_id}/command/set_valet_mode - Set Valet Mode

    + + +
    +
    +

    + + Set Valet Mode + + /api/1/vehicles/{vehicle_id}/command/set_valet_mode +

    +
    +
    +
    + POST + /api/1/vehicles/{vehicle_id}/command/set_valet_mode + + Set Valet Mode + +
    +
    +
    +

    Sets valet mode on or off with a PIN to disable it from within the car. Reuses last PIN from previous valet session.
    +Valet Mode limits the car's top speed to 70MPH and 80kW of acceleration power. It also disables Homelink, Bluetooth and
    +Wifi settings, and the ability to disable mobile access to the car. It also hides your favorites, home, and work
    +locations in navigation.

    +
      +
    • +
      +
      + filter_dramaRequest
      +
      +
      + + -
      - Sets valet mode on or off with a PIN to disable it from within the car. Reuses last PIN from previous valet session. -Valet Mode limits the car's top speed to 70MPH and 80kW of acceleration power. It also disables Homelink, Bluetooth and -Wifi settings, and the ability to disable mobile access to the car. It also hides your favorites, home, and work -locations in navigation. -
      - - -

      CURL Command

      -
      - This might be useful for debugging -
      - +
      Example URI
      + https://owner-api.teslamotors.com +
      Headers
      +
        +
      • + + Authorization: Bearer {access_token} + +
      • +
      + +
      URI Parameters
      +
      + + + + + + + + + + + + +
      keytypestatusdescriptionvalue
      vehicle_idstring requiredThe id of the Vehicle.1
      +
      + +
      Request object
      +
      +
      onboolean Whether to enable or disable valet mode.true
      passwordnumber (optional) A 4 digit PIN code to unlock the car.1234
      +
      -
      -
      - -
      -
      -
      -
      Example URI
      - https://owner-api.teslamotors.com - /api/1/vehicles/1/command/set_valet_mode +
    • + +
    • +
      + publishResponse 200 OK +
      +
      +
      Headers
      -
        -
      • - - Authorization: Bearer {access_token} - -
      • -
      -
      URI Parameters
      - - - - -
      KeyTypeStatusDescriptionValue
      vehicle_idstring required

      The id of the Vehicle.

      -
      1
      -
      Request object
      -
      onboolean

      Whether to enable or disable valet mode.

      -
      true
      passwordnumber

      (optional) A 4 digit PIN code to unlock the car.

      -
      1234
      -
      -
      Headers
      -
        -
      • - - Content-Type: application/json - -
      • -
      -
      -
      -
      application/json
      -
      {
      -  "response": {
      -    "result": true,
      -    "reason": ""
      +                                    
        +
      • + + Content-Type: application/json + +
      • +
      +
      +
      + application/json +
      +
      {
      +  "response": {
      +    "result": true,
      +    "reason": ""
         }
       }
       
      -
      -
      -
      - -
      -
      +
    + -

    - Reset Valet PIN - /api/1/vehicles/{vehicle_id}/command/reset_valet_pin -

    -
    -
    -

    POST - /api/1/vehicles/{vehicle_id}/command/reset_valet_pin - Reset Valet PIN

    + + +
    +
    +

    + + Reset Valet PIN + + /api/1/vehicles/{vehicle_id}/command/reset_valet_pin +

    +
    +
    +
    + POST + /api/1/vehicles/{vehicle_id}/command/reset_valet_pin + + Reset Valet PIN + +
    +
    +
    +

    Resets the PIN set for valet mode, if set.

    +
      +
    • +
      +
      + filter_dramaRequest
      +
      +
      + + -
      - Resets the PIN set for valet mode, if set. -
      - - -

      CURL Command

      -
      - This might be useful for debugging -
      - +
      Example URI
      + https://owner-api.teslamotors.com +
      Headers
      +
        +
      • + + Authorization: Bearer {access_token} + +
      • +
      + +
      URI Parameters
      +
      + + + + + + + + + + + + +
      keytypestatusdescriptionvalue
      vehicle_idstring requiredThe id of the Vehicle.1
      +
      +
      -
      -
      - -
      -
      -
      -
      Example URI
      - https://owner-api.teslamotors.com - /api/1/vehicles/1/command/reset_valet_pin +
    • + +
    • +
      + publishResponse 200 OK +
      +
      +
      Headers
      -
        -
      • - - Authorization: Bearer {access_token} - -
      • -
      -
      URI Parameters
      - - - - -
      KeyTypeStatusDescriptionValue
      vehicle_idstring required

      The id of the Vehicle.

      -
      1
      -
      -
      -
      Headers
      -
        -
      • - - Content-Type: application/json - -
      • -
      -
      -
      -
      application/json
      -
      {
      -  "response": {
      -    "result": true,
      -    "reason": ""
      +                                    
        +
      • + + Content-Type: application/json + +
      • +
      +
      +
      + application/json +
      +
      {
      +  "response": {
      +    "result": true,
      +    "reason": ""
         }
       }
       
      -
      -
      -
      - -
      -
      +
    + -

    - Open Charge Port - /api/1/vehicles/{vehicle_id}/command/charge_port_door_open -

    -
    -
    -

    POST - /api/1/vehicles/{vehicle_id}/command/charge_port_door_open - Open Charge Port

    + + +
    +
    +

    + + Open Charge Port + + /api/1/vehicles/{vehicle_id}/command/charge_port_door_open +

    +
    +
    +
    + POST + /api/1/vehicles/{vehicle_id}/command/charge_port_door_open + + Open Charge Port + +
    +
    +
    +

    Opens the charge port. Does not close the charge port (for now...)

    +
      +
    • +
      +
      + filter_dramaRequest
      +
      +
      + + -
      - Opens the charge port. Does not close the charge port (for now...) -
      - - -

      CURL Command

      -
      - This might be useful for debugging -
      - +
      Example URI
      + https://owner-api.teslamotors.com +
      Headers
      +
        +
      • + + Authorization: Bearer {access_token} + +
      • +
      + +
      URI Parameters
      +
      + + + + + + + + + + + + +
      keytypestatusdescriptionvalue
      vehicle_idstring requiredThe id of the Vehicle.1
      +
      +
      -
      -
      - -
      -
      -
      -
      Example URI
      - https://owner-api.teslamotors.com - /api/1/vehicles/1/command/charge_port_door_open +
    • + +
    • +
      + publishResponse 200 OK +
      +
      +
      Headers
      -
        -
      • - - Authorization: Bearer {access_token} - -
      • -
      -
      URI Parameters
      - - - - -
      KeyTypeStatusDescriptionValue
      vehicle_idstring required

      The id of the Vehicle.

      -
      1
      -
      -
      -
      Headers
      -
        -
      • - - Content-Type: application/json - -
      • -
      -
      -
      -
      application/json
      -
      {
      -  "response": {
      -    "result": true,
      -    "reason": ""
      +                                    
        +
      • + + Content-Type: application/json + +
      • +
      +
      +
      + application/json +
      +
      {
      +  "response": {
      +    "result": true,
      +    "reason": ""
         }
       }
       
      -
      -
      -
      - -
      -
      +
    + -

    - Set Charge Limit to Standard - /api/1/vehicles/{vehicle_id}/command/charge_standard -

    -
    -
    -

    POST - /api/1/vehicles/{vehicle_id}/command/charge_standard - Set Charge Limit to Standard

    + + +
    +
    +

    + + Set Charge Limit to Standard + + /api/1/vehicles/{vehicle_id}/command/charge_standard +

    +
    +
    +
    + POST + /api/1/vehicles/{vehicle_id}/command/charge_standard + + Set Charge Limit to Standard + +
    +
    +
    +

    Set the charge mode to standard (90% under the new percentage system introduced in 4.5).

    +
      +
    • +
      +
      + filter_dramaRequest
      +
      +
      + + -
      - Set the charge mode to standard (90% under the new percentage system introduced in 4.5). -
      - - -

      CURL Command

      -
      - This might be useful for debugging -
      - +
      Example URI
      + https://owner-api.teslamotors.com +
      Headers
      +
        +
      • + + Authorization: Bearer {access_token} + +
      • +
      + +
      URI Parameters
      +
      + + + + + + + + + + + + +
      keytypestatusdescriptionvalue
      vehicle_idstring requiredThe id of the Vehicle.1
      +
      +
      -
      -
      - -
      -
      -
      -
      Example URI
      - https://owner-api.teslamotors.com - /api/1/vehicles/1/command/charge_standard +
    • + +
    • +
      + publishResponse 200 OK +
      +
      +
      Headers
      -
        -
      • - - Authorization: Bearer {access_token} - -
      • -
      -
      URI Parameters
      - - - - -
      KeyTypeStatusDescriptionValue
      vehicle_idstring required

      The id of the Vehicle.

      -
      1
      -
      -
      -
      Headers
      -
        -
      • - - Content-Type: application/json - -
      • -
      -
      -
      -
      application/json
      -
      {
      -  "response": {
      -    "result": false,
      -    "reason": "already_standard"
      +                                    
        +
      • + + Content-Type: application/json + +
      • +
      +
      +
      + application/json +
      +
      {
      +  "response": {
      +    "result": false,
      +    "reason": "already_standard"
         }
       }
       
      -
      -
      -
      - -
      -
      +
    + -

    - Set Charge Limit to Max Range - /api/1/vehicles/{vehicle_id}/command/charge_max_range -

    -
    -
    -

    POST - /api/1/vehicles/{vehicle_id}/command/charge_max_range - Set Charge Limit to Max Range

    + + +
    +
    +

    + + Set Charge Limit to Max Range + + /api/1/vehicles/{vehicle_id}/command/charge_max_range +

    +
    +
    +
    + POST + /api/1/vehicles/{vehicle_id}/command/charge_max_range + + Set Charge Limit to Max Range + +
    +
    +
    +

    Set the charge mode to max range (100% under the new percentage system introduced in 4.5). Use sparingly!

    +
      +
    • +
      +
      + filter_dramaRequest
      +
      +
      + + -
      - Set the charge mode to max range (100% under the new percentage system introduced in 4.5). Use sparingly! -
      - - -

      CURL Command

      -
      - This might be useful for debugging -
      - +
      Example URI
      + https://owner-api.teslamotors.com +
      Headers
      +
        +
      • + + Authorization: Bearer {access_token} + +
      • +
      + +
      URI Parameters
      +
      + + + + + + + + + + + + +
      keytypestatusdescriptionvalue
      vehicle_idstring requiredThe id of the Vehicle.1
      +
      +
      -
      -
      - -
      -
      -
      -
      Example URI
      - https://owner-api.teslamotors.com - /api/1/vehicles/1/command/charge_max_range +
    • + +
    • +
      + publishResponse 200 OK +
      +
      +
      Headers
      -
        -
      • - - Authorization: Bearer {access_token} - -
      • -
      -
      URI Parameters
      - - - - -
      KeyTypeStatusDescriptionValue
      vehicle_idstring required

      The id of the Vehicle.

      -
      1
      -
      -
      -
      Headers
      -
        -
      • - - Content-Type: application/json - -
      • -
      -
      -
      -
      application/json
      -
      {
      -  "response": {
      -    "result": false,
      -    "reason": "already_max_range"
      +                                    
        +
      • + + Content-Type: application/json + +
      • +
      +
      +
      + application/json +
      +
      {
      +  "response": {
      +    "result": false,
      +    "reason": "already_max_range"
         }
       }
       
      -
      -
      -
      - -
      -
      +
    + -

    - Set Charge Limit - /api/1/vehicles/{vehicle_id}/command/set_charge_limit?percent={limit_value} -

    -
    -
    -

    POST - /api/1/vehicles/{vehicle_id}/command/set_charge_limit?percent={limit_value} - Set Charge Limit

    + + +
    +
    +

    + + Set Charge Limit + + /api/1/vehicles/{vehicle_id}/command/set_charge_limit?percent={limit_value} +

    +
    +
    +
    + POST + /api/1/vehicles/{vehicle_id}/command/set_charge_limit?percent={limit_value} + + Set Charge Limit + +
    +
    +
    +

    Set the charge limit to a custom percentage.

    +
      +
    • +
      +
      + filter_dramaRequest
      +
      +
      + + -
      - Set the charge limit to a custom percentage. -
      - - -

      CURL Command

      -
      - This might be useful for debugging -
      - +
      Example URI
      + https://owner-api.teslamotors.com +
      Headers
      +
        +
      • + + Authorization: Bearer {access_token} + +
      • +
      + +
      URI Parameters
      +
      + + + + + + + + + + + + +
      keytypestatusdescriptionvalue
      vehicle_idstring requiredThe id of the Vehicle.1
      limit_valuestring requiredThe percentage value75
      +
      +
      -
      -
      - -
      -
      -
      -
      Example URI
      - https://owner-api.teslamotors.com - /api/1/vehicles/1/command/set_charge_limit?percent=75 +
    • + +
    • +
      + publishResponse 200 OK +
      +
      +
      Headers
      -
        -
      • - - Authorization: Bearer {access_token} - -
      • -
      -
      URI Parameters
      - - - - -
      KeyTypeStatusDescriptionValue
      vehicle_idstring required

      The id of the Vehicle.

      -
      1
      limit_valuestring required

      The percentage value

      -
      75
      -
      -
      -
      Headers
      -
        -
      • - - Content-Type: application/json - -
      • -
      -
      -
      -
      application/json
      -
      {
      -  "response": {
      -    "result": true,
      -    "reason": ""
      +                                    
        +
      • + + Content-Type: application/json + +
      • +
      +
      +
      + application/json +
      +
      {
      +  "response": {
      +    "result": true,
      +    "reason": ""
         }
       }
       
      -
      -
      -
      - -
      -
      +
    + -

    - Start Charging - /api/1/vehicles/{vehicle_id}/command/charge_start -

    -
    -
    -

    POST - /api/1/vehicles/{vehicle_id}/command/charge_start - Start Charging

    + + +
    +
    +

    + + Start Charging + + /api/1/vehicles/{vehicle_id}/command/charge_start +

    +
    +
    +
    + POST + /api/1/vehicles/{vehicle_id}/command/charge_start + + Start Charging + +
    +
    +
    +

    Start charging. Must be plugged in, have power available, and not have reached your charge limit.

    +
      +
    • +
      +
      + filter_dramaRequest
      +
      +
      + + -
      - Start charging. Must be plugged in, have power available, and not have reached your charge limit. -
      - - -

      CURL Command

      -
      - This might be useful for debugging -
      - +
      Example URI
      + https://owner-api.teslamotors.com +
      Headers
      +
        +
      • + + Authorization: Bearer {access_token} + +
      • +
      + +
      URI Parameters
      +
      + + + + + + + + + + + + +
      keytypestatusdescriptionvalue
      vehicle_idstring requiredThe id of the Vehicle.1
      +
      +
      -
      -
      - -
      -
      -
      -
      Example URI
      - https://owner-api.teslamotors.com - /api/1/vehicles/1/command/charge_start +
    • + +
    • +
      + publishResponse 200 OK +
      +
      +
      Headers
      -
        -
      • - - Authorization: Bearer {access_token} - -
      • -
      -
      URI Parameters
      - - - - -
      KeyTypeStatusDescriptionValue
      vehicle_idstring required

      The id of the Vehicle.

      -
      1
      -
      -
      -
      Headers
      -
        -
      • - - Content-Type: application/json - -
      • -
      -
      -
      -
      application/json
      -
      {
      -  "response": {
      -    "result": true,
      -    "reason": "" // "already_started" if a charge is in progress
      +                                    
        +
      • + + Content-Type: application/json + +
      • +
      +
      +
      + application/json +
      +
      {
      +  "response": {
      +    "result": true,
      +    "reason": "" // "already_started" if a charge is in progress
         }
       }
       
      -
      -
      -
      - -
      -
      +
    + -

    - Stop Charging - /api/1/vehicles/{vehicle_id}/command/charge_stop -

    -
    -
    -

    POST - /api/1/vehicles/{vehicle_id}/command/charge_stop - Stop Charging

    + + +
    +
    +

    + + Stop Charging + + /api/1/vehicles/{vehicle_id}/command/charge_stop +

    +
    +
    +
    + POST + /api/1/vehicles/{vehicle_id}/command/charge_stop + + Stop Charging + +
    +
    +
    +

    Stop charging. Must already be charging.

    +
      +
    • +
      +
      + filter_dramaRequest
      +
      +
      + + -
      - Stop charging. Must already be charging. -
      - - -

      CURL Command

      -
      - This might be useful for debugging -
      - +
      Example URI
      + https://owner-api.teslamotors.com +
      Headers
      +
        +
      • + + Authorization: Bearer {access_token} + +
      • +
      + +
      URI Parameters
      +
      + + + + + + + + + + + + +
      keytypestatusdescriptionvalue
      vehicle_idstring requiredThe id of the Vehicle.1
      +
      +
      -
      -
      - -
      -
      -
      -
      Example URI
      - https://owner-api.teslamotors.com - /api/1/vehicles/1/command/charge_stop +
    • + +
    • +
      + publishResponse 200 OK +
      +
      +
      Headers
      -
        -
      • - - Authorization: Bearer {access_token} - -
      • -
      -
      URI Parameters
      - - - - -
      KeyTypeStatusDescriptionValue
      vehicle_idstring required

      The id of the Vehicle.

      -
      1
      -
      -
      -
      Headers
      -
        -
      • - - Content-Type: application/json - -
      • -
      -
      -
      -
      application/json
      -
      {
      -  "response": {
      -    "result": true,
      -    "reason": "" // "not_charging" if a charge was not in progress
      +                                    
        +
      • + + Content-Type: application/json + +
      • +
      +
      +
      + application/json +
      +
      {
      +  "response": {
      +    "result": true,
      +    "reason": "" // "not_charging" if a charge was not in progress
         }
       }
       
      -
      -
      -
      - -
      -
      +
    + -

    - Flash Lights - /api/1/vehicles/{vehicle_id}/command/flash_lights -

    -
    -
    -

    POST - /api/1/vehicles/{vehicle_id}/command/flash_lights - Flash Lights

    + + +
    +
    +

    + + Flash Lights + + /api/1/vehicles/{vehicle_id}/command/flash_lights +

    +
    +
    +
    + POST + /api/1/vehicles/{vehicle_id}/command/flash_lights + + Flash Lights + +
    +
    +
    +

    Flash the lights once.

    +
      +
    • +
      +
      + filter_dramaRequest
      +
      +
      + + -
      - Flash the lights once. -
      - - -

      CURL Command

      -
      - This might be useful for debugging -
      - +
      Example URI
      + https://owner-api.teslamotors.com +
      Headers
      +
        +
      • + + Authorization: Bearer {access_token} + +
      • +
      + +
      URI Parameters
      +
      + + + + + + + + + + + + +
      keytypestatusdescriptionvalue
      vehicle_idstring requiredThe id of the Vehicle.1
      +
      +
      -
      -
      - -
      -
      -
      -
      Example URI
      - https://owner-api.teslamotors.com - /api/1/vehicles/1/command/flash_lights +
    • + +
    • +
      + publishResponse 200 OK +
      +
      +
      Headers
      -
        -
      • - - Authorization: Bearer {access_token} - -
      • -
      -
      URI Parameters
      - - - - -
      KeyTypeStatusDescriptionValue
      vehicle_idstring required

      The id of the Vehicle.

      -
      1
      -
      -
      -
      Headers
      -
        -
      • - - Content-Type: application/json - -
      • -
      -
      -
      -
      application/json
      -
      {
      -  "response": {
      -    "result": true,
      -    "reason": ""
      +                                    
        +
      • + + Content-Type: application/json + +
      • +
      +
      +
      + application/json +
      +
      {
      +  "response": {
      +    "result": true,
      +    "reason": ""
         }
       }
       
      -
      -
      -
      - -
      -
      +
    + -

    - Honk Horn - /api/1/vehicles/{vehicle_id}/command/honk_horn -

    -
    -
    -

    POST - /api/1/vehicles/{vehicle_id}/command/honk_horn - Honk Horn

    + + +
    +
    +

    + + Honk Horn + + /api/1/vehicles/{vehicle_id}/command/honk_horn +

    +
    +
    +
    + POST + /api/1/vehicles/{vehicle_id}/command/honk_horn + + Honk Horn + +
    +
    +
    +

    Honk the horn once.

    +
      +
    • +
      +
      + filter_dramaRequest
      +
      +
      + + -
      - Honk the horn once. -
      - - -

      CURL Command

      -
      - This might be useful for debugging -
      - +
      Example URI
      + https://owner-api.teslamotors.com +
      Headers
      +
        +
      • + + Authorization: Bearer {access_token} + +
      • +
      + +
      URI Parameters
      +
      + + + + + + + + + + + + +
      keytypestatusdescriptionvalue
      vehicle_idstring requiredThe id of the Vehicle.1
      +
      +
      -
      -
      - -
      -
      -
      -
      Example URI
      - https://owner-api.teslamotors.com - /api/1/vehicles/1/command/honk_horn +
    • + +
    • +
      + publishResponse 200 OK +
      +
      +
      Headers
      -
        -
      • - - Authorization: Bearer {access_token} - -
      • -
      -
      URI Parameters
      - - - - -
      KeyTypeStatusDescriptionValue
      vehicle_idstring required

      The id of the Vehicle.

      -
      1
      -
      -
      -
      Headers
      -
        -
      • - - Content-Type: application/json - -
      • -
      -
      -
      -
      application/json
      -
      {
      -  "response": {
      -    "result": true,
      -    "reason": ""
      +                                    
        +
      • + + Content-Type: application/json + +
      • +
      +
      +
      + application/json +
      +
      {
      +  "response": {
      +    "result": true,
      +    "reason": ""
         }
       }
       
      -
      -
      -
      - -
      -
      +
    + -

    - Unlock Doors - /api/1/vehicles/{vehicle_id}/command/door_unlock -

    -
    -
    -

    POST - /api/1/vehicles/{vehicle_id}/command/door_unlock - Unlock Doors

    + + +
    +
    +

    + + Unlock Doors + + /api/1/vehicles/{vehicle_id}/command/door_unlock +

    +
    +
    +
    + POST + /api/1/vehicles/{vehicle_id}/command/door_unlock + + Unlock Doors + +
    +
    +
    +

    Unlock the car's doors.

    +
      +
    • +
      +
      + filter_dramaRequest
      +
      +
      + + -
      - Unlock the car's doors. -
      - - -

      CURL Command

      -
      - This might be useful for debugging -
      - +
      Example URI
      + https://owner-api.teslamotors.com +
      Headers
      +
        +
      • + + Authorization: Bearer {access_token} + +
      • +
      + +
      URI Parameters
      +
      + + + + + + + + + + + + +
      keytypestatusdescriptionvalue
      vehicle_idstring requiredThe id of the Vehicle.1
      +
      +
      -
      -
      - -
      -
      -
      -
      Example URI
      - https://owner-api.teslamotors.com - /api/1/vehicles/1/command/door_unlock +
    • + +
    • +
      + publishResponse 200 OK +
      +
      +
      Headers
      -
        -
      • - - Authorization: Bearer {access_token} - -
      • -
      -
      URI Parameters
      - - - - -
      KeyTypeStatusDescriptionValue
      vehicle_idstring required

      The id of the Vehicle.

      -
      1
      -
      -
      -
      Headers
      -
        -
      • - - Content-Type: application/json - -
      • -
      -
      -
      -
      application/json
      -
      {
      -  "response": {
      -    "result": true,
      -    "reason": ""
      +                                    
        +
      • + + Content-Type: application/json + +
      • +
      +
      +
      + application/json +
      +
      {
      +  "response": {
      +    "result": true,
      +    "reason": ""
         }
       }
       
      -
      -
      -
      - -
      -
      +
    + -

    - Lock Doors - /api/1/vehicles/{vehicle_id}/command/door_lock -

    -
    -
    -

    POST - /api/1/vehicles/{vehicle_id}/command/door_lock - Lock Doors

    + + +
    +
    +

    + + Lock Doors + + /api/1/vehicles/{vehicle_id}/command/door_lock +

    +
    +
    +
    + POST + /api/1/vehicles/{vehicle_id}/command/door_lock + + Lock Doors + +
    +
    +
    +

    Lock the car's doors.

    +
      +
    • +
      +
      + filter_dramaRequest
      +
      +
      + + -
      - Lock the car's doors. -
      - - -

      CURL Command

      -
      - This might be useful for debugging -
      - +
      Example URI
      + https://owner-api.teslamotors.com +
      Headers
      +
        +
      • + + Authorization: Bearer {access_token} + +
      • +
      + +
      URI Parameters
      +
      + + + + + + + + + + + + +
      keytypestatusdescriptionvalue
      vehicle_idstring requiredThe id of the Vehicle.1
      +
      +
      -
      -
      - -
      -
      -
      -
      Example URI
      - https://owner-api.teslamotors.com - /api/1/vehicles/1/command/door_lock +
    • + +
    • +
      + publishResponse 200 OK +
      +
      +
      Headers
      -
        -
      • - - Authorization: Bearer {access_token} - -
      • -
      -
      URI Parameters
      - - - - -
      KeyTypeStatusDescriptionValue
      vehicle_idstring required

      The id of the Vehicle.

      -
      1
      -
      -
      -
      Headers
      -
        -
      • - - Content-Type: application/json - -
      • -
      -
      -
      -
      application/json
      -
      {
      -  "response": {
      -    "result": true,
      -    "reason": ""
      +                                    
        +
      • + + Content-Type: application/json + +
      • +
      +
      +
      + application/json +
      +
      {
      +  "response": {
      +    "result": true,
      +    "reason": ""
         }
       }
       
      -
      -
      -
      - -
      -
      +
    + -

    - Set Temperature - /api/1/vehicles/{vehicle_id}/command/set_temps?driver_temp={driver_degC}&passenger_temp={pass_degC} -

    -
    -
    -

    POST - /api/1/vehicles/{vehicle_id}/command/set_temps?driver_temp={driver_degC}&passenger_temp={pass_degC} - Set Temperature

    + + +
    +
    +

    + + Set Temperature + + /api/1/vehicles/{vehicle_id}/command/set_temps?driver_temp={driver_degC}&passenger_temp={pass_degC} +

    +
    +
    +
    + POST + /api/1/vehicles/{vehicle_id}/command/set_temps?driver_temp={driver_degC}&passenger_temp={pass_degC} + + Set Temperature + +
    +
    +
    +

    Set the temperature target for the HVAC system.

    +
      +
    • +
      +
      + filter_dramaRequest
      +
      +
      + + -
      - Set the temperature target for the HVAC system. -
      - - -

      CURL Command

      -
      - This might be useful for debugging -
      - +
      Example URI
      + https://owner-api.teslamotors.com +
      Headers
      +
        +
      • + + Authorization: Bearer {access_token} + +
      • +
      + +
      URI Parameters
      +
      + + + + + + + + + + + + +
      keytypestatusdescriptionvalue
      vehicle_idstring requiredThe id of the Vehicle.1
      driver_degCstring requiredThe desired temperature on the driver's side in °C.23.7
      pass_degCstring requiredThe desired temperature on the passenger's side in °C.18.1
      +
      +
      -
      -
      - -
      -
      -
      -
      Example URI
      - https://owner-api.teslamotors.com - /api/1/vehicles/1/command/set_temps?driver_temp=23.7&passenger_temp=18.1 +
    • + +
    • +
      + publishResponse 200 OK +
      +
      +
      Headers
      -
        -
      • - - Authorization: Bearer {access_token} - -
      • -
      -
      URI Parameters
      - - - - -
      KeyTypeStatusDescriptionValue
      vehicle_idstring required

      The id of the Vehicle.

      -
      1
      driver_degCstring required

      The desired temperature on the driver's side in °C.

      -
      23.7
      pass_degCstring required

      The desired temperature on the passenger's side in °C.

      -
      18.1
      -
      -
      -
      Headers
      -
        -
      • - - Content-Type: application/json - -
      • -
      -
      -
      -
      application/json
      -
      {
      -  "response": {
      -    "result": true,
      -    "reason": ""
      +                                    
        +
      • + + Content-Type: application/json + +
      • +
      +
      +
      + application/json +
      +
      {
      +  "response": {
      +    "result": true,
      +    "reason": ""
         }
       }
       
      -
      -
      -
      - -
      -
      +
    + + + + + +
    +

    + + Start HVAC System + + /api/1/vehicles/{vehicle_id}/command/auto_conditioning_start +

    +
    +
    +
    + POST + /api/1/vehicles/{vehicle_id}/command/auto_conditioning_start + + Start HVAC System + +
    +
    +
    +

    Start the climate control system. Will cool or heat automatically, depending on set temperature.

    +
      +
    • +
      +
      + filter_dramaRequest
      -

      - Start HVAC System - /api/1/vehicles/{vehicle_id}/command/auto_conditioning_start -

      -
      -
      -

      POST - /api/1/vehicles/{vehicle_id}/command/auto_conditioning_start - Start HVAC System

      +
      + + -
      - Start the climate control system. Will cool or heat automatically, depending on set temperature. -
      - - -

      CURL Command

      -
      - This might be useful for debugging -
      - +
      Example URI
      + https://owner-api.teslamotors.com +
      Headers
      +
        +
      • + + Authorization: Bearer {access_token} + +
      • +
      + +
      URI Parameters
      +
      + + + + + + + + + + + + +
      keytypestatusdescriptionvalue
      vehicle_idstring requiredThe id of the Vehicle.1
      +
      +
      -
      -
      - -
      -
      -
      -
      Example URI
      - https://owner-api.teslamotors.com - /api/1/vehicles/1/command/auto_conditioning_start +
    • + +
    • +
      + publishResponse 200 OK +
      +
      +
      Headers
      -
        -
      • - - Authorization: Bearer {access_token} - -
      • -
      -
      URI Parameters
      - - - - -
      KeyTypeStatusDescriptionValue
      vehicle_idstring required

      The id of the Vehicle.

      -
      1
      -
      -
      -
      Headers
      -
        -
      • - - Content-Type: application/json - -
      • -
      -
      -
      -
      application/json
      -
      {
      -  "response": {
      -    "result": true,
      -    "reason": ""
      +                                    
        +
      • + + Content-Type: application/json + +
      • +
      +
      +
      + application/json +
      +
      {
      +  "response": {
      +    "result": true,
      +    "reason": ""
         }
       }
       
      -
      -
      -
      - -
      -
      +
    + + + + + +
    +

    + + Stop HVAC System + + /api/1/vehicles/{vehicle_id}/command/auto_conditioning_stop +

    +
    +
    +
    + POST + /api/1/vehicles/{vehicle_id}/command/auto_conditioning_stop + + Stop HVAC System + +
    +
    +
    +

    Stop the climate control system.

    +
      +
    • +
      +
      + filter_dramaRequest
      -

      - Stop HVAC System - /api/1/vehicles/{vehicle_id}/command/auto_conditioning_stop -

      -
      -
      -

      POST - /api/1/vehicles/{vehicle_id}/command/auto_conditioning_stop - Stop HVAC System

      +
      + + -
      - Stop the climate control system. -
      - - -

      CURL Command

      -
      - This might be useful for debugging -
      - +
      Example URI
      + https://owner-api.teslamotors.com +
      Headers
      +
        +
      • + + Authorization: Bearer {access_token} + +
      • +
      + +
      URI Parameters
      +
      + + + + + + + + + + + + +
      keytypestatusdescriptionvalue
      vehicle_idstring requiredThe id of the Vehicle.1
      +
      +
      -
      -
      - -
      -
      -
      -
      Example URI
      - https://owner-api.teslamotors.com - /api/1/vehicles/1/command/auto_conditioning_stop +
    • + +
    • +
      + publishResponse 200 OK +
      +
      +
      Headers
      -
        -
      • - - Authorization: Bearer {access_token} - -
      • -
      -
      URI Parameters
      - - - - -
      KeyTypeStatusDescriptionValue
      vehicle_idstring required

      The id of the Vehicle.

      -
      1
      -
      -
      -
      Headers
      -
        -
      • - - Content-Type: application/json - -
      • -
      -
      -
      -
      application/json
      -
      {
      -  "response": {
      -    "result": true,
      -    "reason": ""
      +                                    
        +
      • + + Content-Type: application/json + +
      • +
      +
      +
      + application/json +
      +
      {
      +  "response": {
      +    "result": true,
      +    "reason": ""
         }
       }
       
      -
      -
      -
      - -
      -
      +
    + + + + + +
    +

    + + Move Pano Roof + + /api/1/vehicles/{vehicle_id}/command/sun_roof_control?state={state}&percent={percent} +

    +
    +
    +
    + POST + /api/1/vehicles/{vehicle_id}/command/sun_roof_control?state={state}&percent={percent} + + Move Pano Roof + +
    +
    +
    +

    Controls the car's panoramic roof, if installed.

    +
      +
    • +
      +
      + filter_dramaRequest
      -

      - Move Pano Roof - /api/1/vehicles/{vehicle_id}/command/sun_roof_control?state={state}&percent={percent} -

      -
      -
      -

      POST - /api/1/vehicles/{vehicle_id}/command/sun_roof_control?state={state}&percent={percent} - Move Pano Roof

      +
      + + -
      - Controls the car's panoramic roof, if installed. -
      - - -

      CURL Command

      -
      - This might be useful for debugging -
      - +
      Example URI
      + https://owner-api.teslamotors.com +
      Headers
      +
        +
      • + + Authorization: Bearer {access_token} + +
      • +
      + +
      URI Parameters
      +
      + + + + + + + + + + + + +
      keytypestatusdescriptionvalue
      vehicle_idstring requiredThe id of the Vehicle.1
      stateenum required +The desired state of the panoramic roof. The approximate percent open values for each state are `open` = 100%, `close` = 0%, `comfort` = 80%, and `vent` = ~15% +
      openenum
      percentstring optionalThe percentage to move the roof to.50
      +
      +
      -
      -
      - -
      -
      -
      -
      Example URI
      - https://owner-api.teslamotors.com - /api/1/vehicles/1/command/sun_roof_control?state=open&percent=50 +
    • + +
    • +
      + publishResponse 200 OK +
      +
      +
      Headers
      -
        -
      • - - Authorization: Bearer {access_token} - -
      • -
      -
      URI Parameters
      - - - - -
      KeyTypeStatusDescriptionValue
      vehicle_idstring required

      The id of the Vehicle.

      -
      1
      stateenum required

      The desired state of the panoramic roof. The approximate percent open values for each state are open = 100%, close = 0%, comfort = 80%, and vent = ~15%

      -
      openenum
      percentstring optional

      The percentage to move the roof to.

      -
      50
      -
      -
      -
      Headers
      -
        -
      • - - Content-Type: application/json - -
      • -
      -
      -
      -
      application/json
      -
      {
      -  "response": {
      -    "result": true,
      -    "reason": ""
      +                                    
        +
      • + + Content-Type: application/json + +
      • +
      +
      +
      + application/json +
      +
      {
      +  "response": {
      +    "result": true,
      +    "reason": ""
         }
       }
       
      -
      -
      -
      - -
      -
      +
    + + + + + +
    +

    + + Remote Start + + /api/1/vehicles/{vehicle_id}/command/remote_start_drive?password={password} +

    +
    +
    +
    + POST + /api/1/vehicles/{vehicle_id}/command/remote_start_drive?password={password} + + Remote Start + +
    +
    +
    +

    Start the car for keyless driving. Must start driving within 2 minutes of issuing this request.

    +
      +
    • +
      +
      + filter_dramaRequest
      -

      - Remote Start - /api/1/vehicles/{vehicle_id}/command/remote_start_drive?password={password} -

      -
      -
      -

      POST - /api/1/vehicles/{vehicle_id}/command/remote_start_drive?password={password} - Remote Start

      +
      + + -
      - Start the car for keyless driving. Must start driving within 2 minutes of issuing this request. -
      - - -

      CURL Command

      -
      - This might be useful for debugging -
      - +
      Example URI
      + https://owner-api.teslamotors.com +
      Headers
      +
        +
      • + + Authorization: Bearer {access_token} + +
      • +
      + +
      URI Parameters
      +
      + + + + + + + + + + + + +
      keytypestatusdescriptionvalue
      vehicle_idstring requiredThe id of the Vehicle.1
      passwordstring requiredThe password to the authenticated my.teslamotors.com account.edisonsux
      +
      +
      -
      -
      - -
      -
      -
      -
      Example URI
      - https://owner-api.teslamotors.com - /api/1/vehicles/1/command/remote_start_drive?password=edisonsux +
    • + +
    • +
      + publishResponse 200 OK +
      +
      +
      Headers
      -
        -
      • - - Authorization: Bearer {access_token} - -
      • -
      -
      URI Parameters
      - - - - -
      KeyTypeStatusDescriptionValue
      vehicle_idstring required

      The id of the Vehicle.

      -
      1
      passwordstring required

      The password to the authenticated my.teslamotors.com account.

      -
      edisonsux
      -
      -
      -
      Headers
      -
        -
      • - - Content-Type: application/json - -
      • -
      -
      -
      -
      application/json
      -
      {
      -  "response": {
      -    "result": true,
      -    "reason": ""
      +                                    
        +
      • + + Content-Type: application/json + +
      • +
      +
      +
      + application/json +
      +
      {
      +  "response": {
      +    "result": true,
      +    "reason": ""
         }
       }
       
      -
      -
      -
      - -
      -
      +
    + + + + + +
    +

    + + Open Trunk/Frunk + + /api/1/vehicles/{vehicle_id}/command/trunk_open +

    +
    +
    +
    + POST + /api/1/vehicles/{vehicle_id}/command/trunk_open + + Open Trunk/Frunk + +
    +
    +
    +

    Open the trunk or frunk. Currently inoperable.

    +
      +
    • +
      +
      + filter_dramaRequest
      -

      - Open Trunk/Frunk - /api/1/vehicles/{vehicle_id}/command/trunk_open -

      -
      -
      -

      POST - /api/1/vehicles/{vehicle_id}/command/trunk_open - Open Trunk/Frunk

      +
      + + -
      - Open the trunk or frunk. Currently inoperable. -
      - - -

      CURL Command

      -
      - This might be useful for debugging -
      - +
      Example URI
      + https://owner-api.teslamotors.com +
      Headers
      +
        +
      • + + Authorization: Bearer {access_token} + +
      • +
      + +
      URI Parameters
      +
      + + + + + + + + + + + + +
      keytypestatusdescriptionvalue
      vehicle_idstring requiredThe id of the Vehicle.1
      +
      + +
      Request object
      +
      +
      which_trunkstring The trunk to open. `rear` is the only one known currently.rear
      +
      -
      -
      - -
      -
      -
      -
      Example URI
      - https://owner-api.teslamotors.com - /api/1/vehicles/1/command/trunk_open +
    • + +
    • +
      + publishResponse 200 OK +
      +
      +
      Headers
      -
        -
      • - - Authorization: Bearer {access_token} - -
      • -
      -
      URI Parameters
      - - - - -
      KeyTypeStatusDescriptionValue
      vehicle_idstring required

      The id of the Vehicle.

      -
      1
      -
      Request object
      -
      which_trunkstring

      The trunk to open. rear is the only one known currently.

      -
      rear
      -
      -
      Headers
      -
        -
      • - - Content-Type: application/json - -
      • -
      -
      -
      -
      application/json
      -
      {
      -  "response": {
      -    "result": true,
      -    "reason": ""
      +                                    
        +
      • + + Content-Type: application/json + +
      • +
      +
      +
      + application/json +
      +
      {
      +  "response": {
      +    "result": true,
      +    "reason": ""
         }
       }
       
      -
      -
      -
      - -
      -
      +
    + - - + + + +
    + - - + info_outline + +
    +
    +
    Metadata
    +

    This button shows the metadata for the API

    +
    +
    + + + - - + + +anchors.options = { + placement: 'left', + visible: 'touch', +}; +anchors.add('.main-content h1, .main-content h2, .main-content h3, .main-content .card-header a'); \ No newline at end of file diff --git a/tests/statics/full_test.apib b/tests/statics/full_test.apib index 9599b6da..6fabdf32 100644 --- a/tests/statics/full_test.apib +++ b/tests/statics/full_test.apib @@ -97,10 +97,44 @@ Updates a specific Post. + Request (application/json) + {"test": true} ++ Request (application/xml) + + ++ Request Something (application/xml) + + + + Response 200 [Post][] ++ Response 204 (application/json) + ++ Response 301 (application/json) + ++ Response 302 (application/json) + ++ Response 400 (application/json) + + { "post" : "invalid data" } + + ++ Response 400 (text/xml) + + Invalid DATA + + ++ Response 401 (application/json) + + { "post" : "not allowed" } + + ++ Response 403 (application/json) + + { "post" : "denied" } + + ### Delete a Post [DELETE] Delete a Post. The current user must be the same user who created the Post. It returns the deleted Post on success. From 3c11517d45c24e505741d9650b78d4244eba8c90 Mon Sep 17 00:00:00 2001 From: Sean Molenaar Date: Sat, 1 Aug 2020 20:38:37 +0200 Subject: [PATCH 2/3] Drop php 7.2 support --- .github/workflows/test.yml | 2 +- composer.json | 2 +- composer.lock | 4 ++-- phpstan.neon | 10 ---------- phpstan.neon.dist | 11 +++++++++++ 5 files changed, 15 insertions(+), 14 deletions(-) delete mode 100644 phpstan.neon create mode 100644 phpstan.neon.dist diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0b1a6156..be64dd92 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,7 @@ jobs: name: PHP ${{ matrix.php-versions }} strategy: matrix: - php-versions: ['7.2', '7.3', '7.4'] + php-versions: ['7.3', '7.4'] steps: - name: Checkout uses: actions/checkout@v1 diff --git a/composer.json b/composer.json index 67434f97..52ce2e82 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ } ], "require": { - "php": "^7.2", + "php": "^7.3", "ql/uri-template": "~1.0", "vanilla/garden-cli": "~2.0", "michelf/php-markdown": "~1.9", diff --git a/composer.lock b/composer.lock index 12f2f176..eb938298 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "cef77d685f965805646c3f88d2417d06", + "content-hash": "e4a29b1c5127dc6133b6125f20332663", "packages": [ { "name": "lukasoppermann/http-status", @@ -2869,7 +2869,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": "^7.2", + "php": "^7.3", "ext-json": "*", "ext-curl": "*" }, diff --git a/phpstan.neon b/phpstan.neon deleted file mode 100644 index 5cc8827b..00000000 --- a/phpstan.neon +++ /dev/null @@ -1,10 +0,0 @@ -parameters: - bootstrap: tests/test.bootstrap.inc.php - excludes_analyse: - - src/PHPDraft/Out/Version.php - - src/PHPDraft/Parse/Tests/BaseParserTest.php - - src/PHPDraft/Parse/Tests/DrafterTest.php - - src/PHPDraft/Parse/Tests/DrafterAPITest.php - ignoreErrors: - - '#Access to an undefined property object::\$[a-zA-Z0-9\\_]+#' - - '#Access to an undefined property PHPDraft\\Model\\HierarchyElement::\$[a-zA-Z0-9_]+#' \ No newline at end of file diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 00000000..f2e78723 --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,11 @@ +parameters: + bootstrapFiles: + - tests/test.bootstrap.inc.php + excludes_analyse: + - src/PHPDraft/Out/Version.php + - src/PHPDraft/Parse/Tests/BaseParserTest.php + - src/PHPDraft/Parse/Tests/DrafterTest.php + - src/PHPDraft/Parse/Tests/DrafterAPITest.php + ignoreErrors: + - '#Access to an undefined property object::\$[a-zA-Z0-9\\_]+#' + - '#Access to an undefined property PHPDraft\\Model\\HierarchyElement::\$[a-zA-Z0-9_]+#' \ No newline at end of file From d0b8cd17c96032dae4fa2018188e2cc9711dbf15 Mon Sep 17 00:00:00 2001 From: Sean Molenaar Date: Sat, 1 Aug 2020 22:21:40 +0200 Subject: [PATCH 3/3] Fix coverage --- .github/workflows/test.yml | 23 ++++- .gitignore | 2 + composer.json | 3 + src/PHPDraft/In/Tests/ApibFileParserTest.php | 10 ++ src/PHPDraft/Model/Resource.php | 3 - src/PHPDraft/Model/Tests/ResourceTest.php | 37 ++------ src/PHPDraft/Out/HTML/material/category.twig | 11 --- src/PHPDraft/Out/HTML/material/resource.twig | 27 ------ src/PHPDraft/Out/TemplateRenderer.php | 28 +++--- .../Out/Tests/TemplateRendererTest.php | 89 +++++++++++++++++- src/PHPDraft/Out/Tests/TwigFactoryTest.php | 23 +++++ src/PHPDraft/Out/TwigFactory.php | 1 + .../Parse/Tests/HtmlGeneratorTest.php | 2 +- tests/phpunit.xml | 1 + tests/statics/basic_html_template | 51 ++++++++++ tests/statics/drafter/html/basic.html | 93 +------------------ tests/statics/drafter/html/material.html | 2 +- tests/statics/empty_html_template | 41 ++++++++ tests/statics/full_html_template | 54 +++++++++++ 19 files changed, 320 insertions(+), 181 deletions(-) delete mode 100644 src/PHPDraft/Out/HTML/material/category.twig delete mode 100644 src/PHPDraft/Out/HTML/material/resource.twig create mode 100644 src/PHPDraft/Out/Tests/TwigFactoryTest.php create mode 100644 tests/statics/basic_html_template create mode 100644 tests/statics/empty_html_template create mode 100644 tests/statics/full_html_template diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index be64dd92..6c989f15 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -69,20 +69,33 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v1 + uses: actions/checkout@v2 - - name: Download coverage - uses: actions/download-artifact@v1 + - name: Setup PHP + uses: shivammathur/setup-php@v2 with: - name: coverage + php-version: 7.4 + coverage: pcov + extensions: curl,json,mbstring,uopz + tools: pecl,phpunit + + - name: Install Composer deps + run: composer update --no-interaction --no-suggest + + - name: Run test suite + run: composer run-script test-sonar - name: Code coverage Scan uses: codecov/codecov-action@v1 with: token: ${{ secrets.CODECOV_TOKEN }} + - name: Change paths in clover.xml + run: | + sed -i 's+/home/runner/work/bundle-stripe/bundle-stripe+/github/workspace+g' ./var/coverage/clover.xml + - name: SonarCloud Scan - uses: sonarsource/sonarcloud-github-action@v1.1 + uses: sonarsource/sonarcloud-github-action@v1.3 continue-on-error: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 4737429c..6e0d9638 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,5 @@ atlassian-ide-plugin.xml *.pem /index.html + +/coverage.xml diff --git a/composer.json b/composer.json index 52ce2e82..01352ccc 100644 --- a/composer.json +++ b/composer.json @@ -41,6 +41,9 @@ "test": [ "vendor/bin/phpunit --configuration tests/phpunit.xml --coverage-clover=coverage.xml" ], + "test-sonar": [ + "vendor/bin/phpunit --configuration tests/phpunit.xml --coverage-clover=./var/coverage/clover.xml" + ], "phar": [ "vendor/bin/phing phar", "sha256sum build/out/*" diff --git a/src/PHPDraft/In/Tests/ApibFileParserTest.php b/src/PHPDraft/In/Tests/ApibFileParserTest.php index a11c09a6..3612aa8c 100644 --- a/src/PHPDraft/In/Tests/ApibFileParserTest.php +++ b/src/PHPDraft/In/Tests/ApibFileParserTest.php @@ -102,4 +102,14 @@ public function testParseBasic(): void $this->assertSame($text, $full_property->getValue($this->class)); $this->assertSame($text, $this->class->__toString()); } + + /** + * Test setting content + * + * @covers \PHPDraft\In\ApibFileParser::set_apib_content + */ + public function testSetContent(){ + $this->class->set_apib_content('content'); + $this->assertEquals('content', $this->get_reflection_property_value('full_apib')); + } } diff --git a/src/PHPDraft/Model/Resource.php b/src/PHPDraft/Model/Resource.php index 1d37d8eb..d62335a2 100644 --- a/src/PHPDraft/Model/Resource.php +++ b/src/PHPDraft/Model/Resource.php @@ -65,9 +65,6 @@ public function parse(stdClass $object): self } foreach ($object->content as $item) { - if ($item->element === 'copy') { - continue; - } $transition = new Transition($this); $this->children[] = $transition->parse($item); } diff --git a/src/PHPDraft/Model/Tests/ResourceTest.php b/src/PHPDraft/Model/Tests/ResourceTest.php index c40aab62..760d748f 100644 --- a/src/PHPDraft/Model/Tests/ResourceTest.php +++ b/src/PHPDraft/Model/Tests/ResourceTest.php @@ -61,16 +61,12 @@ public function testSetupCorrectly(): void */ public function testParseIsCalled(): void { - $property = $this->reflection->getProperty('parent'); - $property->setAccessible(true); - $property->setValue($this->class, $this->parent); + $this->set_reflection_property_value('parent', $this->parent); - $obj = '{"attributes":{"href":"something"}, "content":[]}'; + $obj = '{"attributes":{"href": "something", "hrefVariables":{"content": [{}]}}, "content":[]}'; $this->class->parse(json_decode($obj)); - $this->assertSame($this->parent, $property->getValue($this->class)); - $href_property = $this->reflection->getProperty('href'); $href_property->setAccessible(true); $this->assertSame('something', $href_property->getValue($this->class)); @@ -81,16 +77,12 @@ public function testParseIsCalled(): void */ public function testParseIsCalledNoHREF(): void { - $property = $this->reflection->getProperty('parent'); - $property->setAccessible(true); - $property->setValue($this->class, $this->parent); + $this->set_reflection_property_value('parent', $this->parent); $obj = '{"content":[]}'; $this->class->parse(json_decode($obj)); - $this->assertSame($this->parent, $property->getValue($this->class)); - $href_property = $this->reflection->getProperty('href'); $href_property->setAccessible(true); $this->assertNull($href_property->getValue($this->class)); @@ -101,19 +93,13 @@ public function testParseIsCalledNoHREF(): void */ public function testParseIsCalledIsCopy(): void { - $property = $this->reflection->getProperty('parent'); - $property->setAccessible(true); - $property->setValue($this->class, $this->parent); + $this->set_reflection_property_value('parent', $this->parent); $obj = '{"content":[{"element":"copy", "content":""},{"element":"hello", "content":""}, {"element":"hello", "content":""}]}'; $this->class->parse(json_decode($obj)); - $this->assertSame($this->parent, $property->getValue($this->class)); - - $href_property = $this->reflection->getProperty('href'); - $href_property->setAccessible(true); - $this->assertNull($href_property->getValue($this->class)); + $this->assertNull($this->get_reflection_property_value('href')); } /** @@ -121,19 +107,14 @@ public function testParseIsCalledIsCopy(): void */ public function testParseIsCalledIsNotCopy(): void { - $property = $this->reflection->getProperty('parent'); - $property->setAccessible(true); - $property->setValue($this->class, $this->parent); - - $child_property = $this->reflection->getProperty('children'); - $child_property->setAccessible(true); - $this->assertEmpty($child_property->getValue($this->class)); + $this->set_reflection_property_value('parent', $this->parent); + $this->assertEmpty($this->get_reflection_property_value('children')); $obj = '{"content":[{"element":"hello", "content":""}]}'; $this->class->parse(json_decode($obj)); - $this->assertSame($this->parent, $property->getValue($this->class)); - $this->assertNotEmpty($child_property->getValue($this->class)); + $this->assertSame($this->parent, $this->get_reflection_property_value('parent')); + $this->assertNotEmpty($this->get_reflection_property_value('children')); } } diff --git a/src/PHPDraft/Out/HTML/material/category.twig b/src/PHPDraft/Out/HTML/material/category.twig deleted file mode 100644 index b1ace96e..00000000 --- a/src/PHPDraft/Out/HTML/material/category.twig +++ /dev/null @@ -1,11 +0,0 @@ -
    -{% if category.title %} -

    {{ category.title }}

    -{% endif %} -{% if category.description %} -

    {{ category.description|markdown_to_html }}

    -{% endif %} -{% for resource in category.children %} - {% include 'resource.twig' %} -{% endfor %} -
    \ No newline at end of file diff --git a/src/PHPDraft/Out/HTML/material/resource.twig b/src/PHPDraft/Out/HTML/material/resource.twig deleted file mode 100644 index 884f75cd..00000000 --- a/src/PHPDraft/Out/HTML/material/resource.twig +++ /dev/null @@ -1,27 +0,0 @@ -
    -

    - - {{ resource.title }} - - {{ resource.href }} -

    -{% if resource.description %} - {{ resource.description|markdown_to_html }} -{% endif %} -{% if resource.url_variables %} -
    URI Parameters
    -
    - - - - {% for url_variable in resource.url_variables %}{{ url_variable|raw }}{% endfor %} - -
    keytypestatusdescriptionvalue
    -
    -{% endif %} -{% for transition in resource.children %} - {% include 'transition.twig' %} -{% endfor %} -
    \ No newline at end of file diff --git a/src/PHPDraft/Out/TemplateRenderer.php b/src/PHPDraft/Out/TemplateRenderer.php index c103bc32..6ec723d4 100644 --- a/src/PHPDraft/Out/TemplateRenderer.php +++ b/src/PHPDraft/Out/TemplateRenderer.php @@ -15,6 +15,7 @@ use Lukasoppermann\Httpstatus\Httpstatus; use PHPDraft\Model\Category; use PHPDraft\Model\Elements\ArrayStructureElement; +use PHPDraft\Model\Elements\ElementStructureElement; use PHPDraft\Model\Elements\EnumStructureElement; use PHPDraft\Model\Elements\ObjectStructureElement; use PHPDraft\Parse\ExecutionException; @@ -61,7 +62,7 @@ public function __construct(string $template, ?string $image) */ public function get($object): string { - $include = $this->find_include_file($this->template); + $include = $this->find_include_file($this->template, 'twig', false); if ($include === null) { throw new ExecutionException("Couldn't find template '$this->template'", 1); } @@ -73,24 +74,23 @@ public function get($object): string } if (Sorting::sortServices($this->sorting)) { - usort($this->categories, function ($a, $b) { - return strcmp($a->title, $b->title); - }); + usort($this->categories, function ($a, $b) { return strcmp($a->title, $b->title); }); foreach ($this->categories as $category) { - usort($category->children, function ($a, $b) { - return strcmp($a->title, $b->title); - }); + usort($category->children, function ($a, $b) { return strcmp($a->title, $b->title); }); } } - $loader = new FilesystemLoader(stream_resolve_include_path(dirname($include))); + $loader = new FilesystemLoader([]); + $loader->addPath(stream_resolve_include_path(dirname($include))); + $loader->addPath(stream_resolve_include_path(dirname($this->find_include_file('default', 'twig')))); + $twig = TwigFactory::get($loader); $template = $twig->load('main.twig'); $extras = array_filter($this->base_data, function ($value) { return !in_array($value, ['HOST', 'TITLE', 'ALT_HOST', 'FORMAT', 'DESC', 'COLOR_1', 'COLOR_2']); }, ARRAY_FILTER_USE_KEY); - $extras['host'] = $this->base_data['HOST']; + $extras['host'] = $this->base_data['HOST'] ?? null; return $template->render([ 'data' => $this->base_data, @@ -117,6 +117,8 @@ private function parse_base_data(object $object): void return; } + $this->base_data['TITLE'] = $object->content[0]->meta->title->content ?? ''; + foreach ($object->content[0]->attributes->metadata->content as $meta) { $this->base_data[$meta->content->key->content] = $meta->content->value->content; } @@ -130,14 +132,12 @@ private function parse_base_data(object $object): void $cat = new Category(); $cat = $cat->parse($value); - if (isset($value->meta->classes->content[0]->content) && $value->meta->classes->content[0]->content === 'dataStructures') { + if (($value->meta->classes->content[0]->content ?? null) === 'dataStructures') { $this->base_structures = array_merge($this->base_structures, $cat->structures); } else { $this->categories[] = $cat; } } - - $this->base_data['TITLE'] = $object->content[0]->meta->title->content ?? ''; } /** @@ -148,7 +148,7 @@ private function parse_base_data(object $object): void * * @return null|string File path or null if not found */ - public function find_include_file(string $template, string $extension = 'twig'): ?string + public function find_include_file(string $template, string $extension = 'twig', bool $fallback = true): ?string { $include = null; $includes = [ @@ -167,7 +167,7 @@ public function find_include_file(string $template, string $extension = 'twig'): return $include; } - if (in_array($extension, ['twig', 'js', 'css']) && $template !== 'default') { + if (in_array($extension, ['twig', 'js', 'css']) && $template !== 'default' && $fallback === true) { return $this->find_include_file('default', $extension); } diff --git a/src/PHPDraft/Out/Tests/TemplateRendererTest.php b/src/PHPDraft/Out/Tests/TemplateRendererTest.php index 3c6d991d..5fa66576 100644 --- a/src/PHPDraft/Out/Tests/TemplateRendererTest.php +++ b/src/PHPDraft/Out/Tests/TemplateRendererTest.php @@ -36,6 +36,8 @@ public function setUp(): void /** * Test if the value the class is initialized with is correct + * + * @covers \PHPDraft\Out\TemplateRenderer */ public function testSetupCorrectly(): void { @@ -45,6 +47,8 @@ public function testSetupCorrectly(): void /** * Test if the value the class is initialized with is correct + * + * @covers \PHPDraft\Out\TemplateRenderer::strip_link_spaces */ public function testStripSpaces(): void { @@ -75,10 +79,12 @@ public function responseStatusProvider(): array * * @param int $code HTTP code * @param string $text Class to return + * + * @covers \PHPDraft\Out\TemplateRenderer::get_response_status */ public function testResponseStatus($code, $text): void { - $return = $this->class->get_response_status($code); + $return = TemplateRenderer::get_response_status($code); $this->assertEquals($text, $return); } @@ -111,15 +117,19 @@ public function requestMethodProvider(): array * * @param int $code HTTP Method * @param string $text Class to return + * + * @covers \PHPDraft\Out\TemplateRenderer::get_method_icon */ public function testRequestMethod($code, $text): void { - $return = $this->class->get_method_icon($code); + $return = TemplateRenderer::get_method_icon($code); $this->assertEquals($text, $return); } /** * Test if the value the class is initialized with is correct + * + * @covers \PHPDraft\Out\TemplateRenderer::find_include_file */ public function testIncludeFileDefault(): void { @@ -129,6 +139,8 @@ public function testIncludeFileDefault(): void /** * Test if the value the class is initialized with is correct + * + * @covers \PHPDraft\Out\TemplateRenderer::find_include_file */ public function testIncludeFileFallback(): void { @@ -138,6 +150,8 @@ public function testIncludeFileFallback(): void /** * Test if the value the class is initialized with is correct + * + * @covers \PHPDraft\Out\TemplateRenderer::find_include_file */ public function testIncludeFileNone(): void { @@ -147,6 +161,8 @@ public function testIncludeFileNone(): void /** * Test if the value the class is initialized with is correct + * + * @covers \PHPDraft\Out\TemplateRenderer::find_include_file */ public function testIncludeFileSingle(): void { @@ -157,6 +173,8 @@ public function testIncludeFileSingle(): void /** * Test if the value the class is initialized with is correct + * + * @covers \PHPDraft\Out\TemplateRenderer::find_include_file */ public function testIncludeFileMultiple(): void { @@ -170,4 +188,71 @@ public function testIncludeFileMultiple(): void $return = $this->class->find_include_file('text', 'txt'); $this->assertEquals('templates/text/text.txt', $return); } + + /** + * @covers \PHPDraft\Out\TemplateRenderer::get + */ + public function testGetTemplateFailsEmpty(): void { + $this->expectException('PHPDraft\Parse\ExecutionException'); + $this->expectExceptionMessage('Couldn\'t find template \'cow\''); + $this->set_reflection_property_value('template', 'cow'); + $json = '{"content": [{"content": "hello"}]}'; + + $this->assertStringEqualsFile(TEST_STATICS . '/empty_html_template', $this->class->get(json_decode($json))); + } + + /** + * @covers \PHPDraft\Out\TemplateRenderer::get + */ + public function testGetTemplate(): void { + $json = '{"content": [{"content": "hello"}]}'; + + $this->assertStringEqualsFile(TEST_STATICS . '/empty_html_template', $this->class->get(json_decode($json))); + } + + /** + * @covers \PHPDraft\Out\TemplateRenderer::get + */ + public function testGetTemplateSorting(): void { + $this->set_reflection_property_value('sorting', 3); + $json = '{"content": [{"content": "hello"}]}'; + + $this->assertStringEqualsFile(TEST_STATICS . '/empty_html_template', $this->class->get(json_decode($json))); + } + + /** + * @covers \PHPDraft\Out\TemplateRenderer::get + */ + public function testGetTemplateMetaData(): void { + $this->set_reflection_property_value('sorting', 3); + $json = <<<'TAG' +{"content": [{"content": [], "attributes": { +"metadata": {"content": [ +{"content":{"key": {"content": "key"}, "value": {"content": "value"}}} +]}, +"meta": {"title": {"content": "title"}} +}}]} +TAG; + + $this->assertStringEqualsFile(TEST_STATICS . '/basic_html_template', $this->class->get(json_decode($json))); + } + + /** + * @covers \PHPDraft\Out\TemplateRenderer::get + */ + public function testGetTemplateCategories(): void { + $this->set_reflection_property_value('sorting', 3); + $json = <<<'TAG' +{"content": [ +{"content": [{"element": "copy", "content": "__desc__"}, {"element": "category", "content": []}], + "attributes": { +"metadata": {"content": [ +{"content":{"key": {"content": "key"}, "value": {"content": "value"}}} +]}, +"meta": {"title": {"content": "title"}} +}}]} +TAG; + + $this->assertStringEqualsFile(TEST_STATICS . '/full_html_template', $this->class->get(json_decode($json))); + } } diff --git a/src/PHPDraft/Out/Tests/TwigFactoryTest.php b/src/PHPDraft/Out/Tests/TwigFactoryTest.php new file mode 100644 index 00000000..3d5b73f8 --- /dev/null +++ b/src/PHPDraft/Out/Tests/TwigFactoryTest.php @@ -0,0 +1,23 @@ +assertInstanceOf(Environment::class, TwigFactory::get($loader)); + } +} diff --git a/src/PHPDraft/Out/TwigFactory.php b/src/PHPDraft/Out/TwigFactory.php index 616715f5..e173bc7c 100644 --- a/src/PHPDraft/Out/TwigFactory.php +++ b/src/PHPDraft/Out/TwigFactory.php @@ -60,6 +60,7 @@ public function load($class) { if (MarkdownRuntime::class === $class) { return new MarkdownRuntime(new DefaultMarkdown()); } + return null; } }); $twig->addExtension(new MarkdownExtension()); diff --git a/src/PHPDraft/Parse/Tests/HtmlGeneratorTest.php b/src/PHPDraft/Parse/Tests/HtmlGeneratorTest.php index af81ef81..fb8cb027 100644 --- a/src/PHPDraft/Parse/Tests/HtmlGeneratorTest.php +++ b/src/PHPDraft/Parse/Tests/HtmlGeneratorTest.php @@ -89,7 +89,7 @@ public function testGetHTMLMaterial(): void */ public function testGetHTMLAdvanced(): void { - $this->class->build_html('temp', 'img.jpg', 'test.css,index.css', 'index.js,test.js'); + $this->class->build_html('material', 'img.jpg', 'test.css,index.css', 'index.js,test.js'); $this->assertMatchesRegularExpression('//', $this->class->__toString()); $this->assertMatchesRegularExpression('/ + + + + + + \ No newline at end of file diff --git a/tests/statics/drafter/html/basic.html b/tests/statics/drafter/html/basic.html index 110a9621..62785036 100644 --- a/tests/statics/drafter/html/basic.html +++ b/tests/statics/drafter/html/basic.html @@ -6,7 +6,7 @@ - +
    @@ -3389,93 +3389,8 @@
    Headers
    - + \ No newline at end of file diff --git a/tests/statics/drafter/html/material.html b/tests/statics/drafter/html/material.html index f5eaf57a..54a7b632 100644 --- a/tests/statics/drafter/html/material.html +++ b/tests/statics/drafter/html/material.html @@ -7,7 +7,7 @@ - +
    diff --git a/tests/statics/empty_html_template b/tests/statics/empty_html_template new file mode 100644 index 00000000..368ae0a6 --- /dev/null +++ b/tests/statics/empty_html_template @@ -0,0 +1,41 @@ + + + + + + + + + + + +
    +
    +
    +

    + +

    +
    +
    + + Image + +
    +
    +
    +
    +
    +
    +
    + + + + + + + + \ No newline at end of file diff --git a/tests/statics/full_html_template b/tests/statics/full_html_template new file mode 100644 index 00000000..ceb0e3ec --- /dev/null +++ b/tests/statics/full_html_template @@ -0,0 +1,54 @@ + + + + + + + + + + + +
    +
    +
    +

    + +

    +

    desc

    + +
    +
    + + Image + +
    +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + \ No newline at end of file