Jane 5.0 has been released! đŸ
Jane is a set of libraries to generate models & API clients based on OpenApi specs. It will generate everything you need to use your API such as endpoints and related exceptions if needed.
As a reminder, OpenApi Specification is an API description format or API definition language. Basically, an OpenApi Specification allows you to describe an API including (among other things):
- General information about the API
- Available paths (
/resources) - Available operations on each path (
get /resources) - Input/Output for each operation
The previous version of JanePHP was released in February 2018 and used OpenApi 2 specification, async support and our first documentation.
Since that release, Janeâs OpenApi library has been installed more than 40,000 times đ.
At JoliCode, we are using Jane in a lot of different projects, to make API communication simpler and to build full API clients, such as: Slack, Docker, Harvest or Forecast.
Section intitulĂ©e why-is-jane-5-cooler-than-4Why is Jane 5 cooler than 4? đ
A year after the previous version, we chose to release Jane 5.0 with two major features:
Section intitulĂ©e openapi-3â0â2-supportOpenApi 3.0.2 support đ
Since Swagger 2.0 (OpenApi is the new name of Swagger), a lot of changes has been made:
definitionsbecomescomponents/schemas;- Inside endpoint parameters, model definition is now indexed by a
schemakey; - Again in endpoint parameters,
in: bodyobjects have a new separated field calledrequestBody; - Better support for content-type negotiation.
Many other features can be found on OpenApi 3.0 release blog post or the very detailed ReadMe blog post.
Section intitulĂ©e psr-18-client-generationPSR-18 Client generation đ
PSR-18 is a standard made by PHP-FIG to harmonize HTTP Clients among PHP.
This allows us to use any PSR-18 compatible client (including Symfonyâs HttpClient component). With this release itâs preferable to use a PSR-18 Client than HTTPlug.
Section intitulĂ©e a-quick-exampleA quick example đ
First, youâll need to require jane-php packages:
composer require --dev jane-php/open-api "^5.0"
composer require jane-php/open-api-runtime "^5.0"
OpenApi package is only needed to generate classes. OpenApiRuntime is needed to use theses classes.
Now, we need to configure Jane before generation. We create a .jane-openapi file:
return [
'openapi-file' => __DIR__ . '/schema.yaml',
'namespace' => 'CatFacts\Api',
'directory' => __DIR__ . '/generated/',
];
It will contain a reference to your main schema file, the PHP namespace you want for generated classes and the directory you want to use. Other configuration can be made in that file, read more in the documentation about it. Also, the schema used here can be found in the documentation with more details.
After that, one line will generate classes based on your schema:
$ vendor/bin/jane-openapi generate
Then you can use them to communicate with your API đ
$ tree generated/
generated/
âââ Client.php
âââ Endpoint
â âââ RandomFact.php
âââ Model
â âââ Fact.php
âââ Normalizer
âââ FactNormalizer.php
âââ NormalizerFactory.php
3 directories, 5 files
Section intitulĂ©e want-to-go-furtherWant to go further? đ¶
Here is the full working example or read the documentation.
We are using Jane every day and on many projects, we will continue to update and implement more features. If you want to contribute, you can help us by checking issues. If you donât know how to contribute, you can follow our guide about contributing on Jane and how the library works.
Commentaires et discussions
Nos articles sur le mĂȘme sujet
Pourquoi nous aimons le FOSDEM đ
Le FOSDEM, câest le Free and Open source Softwares Developers European Meeting, ou en Français : rassemblement europĂ©en des dĂ©veloppeurs de logiciels libres et Open Source. Cette confĂ©rence se tient sur deux joursâŠ
par Marion Hurteau
Jane v5.3: Performances, Authentication & OpenAPI 2!
Two months after v5.2 and four months after v5.0, we are releasing v5.3 with focus on three things: Performance Before, generating a really big OpenAPI schema was very long. We even had issues where the generationâŠ
par Baptiste Leduc
Nos formations sur ce sujet
Notre expertise est aussi disponible sous forme de formations professionnelles !
Symfony avancée
DĂ©couÂvrez les foncÂtionÂnaÂliÂtĂ©s et concepts avanÂcĂ©s de SymfoÂny
Ces clients ont profité de notre expertise
Ă lâoccasion de la 12e Ă©dition du concours Europan Europe, JoliCode a conçu la plateforme technique du concours. Ce site permet la prĂ©sentation des diffĂ©rents sites pour lesquels il y a un appel Ă projets, et encadre le processus de recueil des projets soumis par des milliers dâarchitectes candidats. Lâapplication gĂšre Ă©galement toute la partie post-concoursâŠ
JoliCode continue dâaccompagner les Ă©quipes web dâAfflelou en assurant la maintenance des diffĂ©rentes applications constituant la plateforme Web B2C. Nous mettons en place des bonnes pratiques avec PHPStan et Rector, procĂ©dons Ă la montĂ©e de version de PHP et Symfony, optimisons le code grĂące au profiling, et collaborons avec lâinfogĂ©reur pour lesâŠ
Nous avons dĂ©veloppĂ© une plateforme de site gĂ©nĂ©riques autour de lâAPI Phraseanet. Ă lâaide de Silex de composants Symfony2, nous avons accompagnĂ© Alchemy dans la rĂ©alisation dâun site dĂ©clinable pour leurs clients. Le produit est intĂ©gralement configurable et supporte de nombreux systĂšmes dâauthentification (Ldap, OAuth2, Doctrine ou anonyme).