Skip to content

This fork includes branches with adapted versions of React Generator based on the Tutorial API Platform.

License

Notifications You must be signed in to change notification settings

metaclass-nl/client-generator

 
 

Repository files navigation

API Platform Create Client

GitHub Actions npm version

API Platform Create Client is a generator to scaffold apps with Create-Retrieve-Update-Delete features for any API exposing a Hydra or OpenAPI documentation for:

  • Next.js
  • Nuxt
  • Quasar
  • React
  • React Native
  • TypeScript Interfaces
  • Vue.js
  • Vuetify.js

Works especially well with APIs built with the API Platform framework.

Adapted version

This fork includes branches with adapted versions of React Generator based on the Tutorial API Platform. that can be used to scaffold more user friendly Internationalized and Localized React applications. The following branches are available:

  • tutorial-chapter3 with Internationalization and Localization (uses React Intl)
  • tutorial-chapter4 with the above and showing entity labels/names instead of @ids (requires corresponding serialization group annotations on the api)
  • tutorial-chapter6 with the above and Searching and Sorting (requires manual adaptation, the above and corresponding filter annotations on the api)

There is no branche for chapter 7 (Authorization, JWT) because it only requires 2 components and no scaffolding, you can follow the instructions of the chapter7-react branch of the tutorial.

To use one of them first read the instructions in the readme of the branch (follow its link to github). Then follow the instructions on installing an api platform distribution or react client and find the client src folder.

Then clone the repository somewhere where you can run npm or yarn:

git clone https:/metaclass-nl/client-generator.git

Check out the branch (replace with the branch of your choice):

git checkout tutorial-chapter6

With npm you can and build it like:

npm run build

With npm you can run the actual scaffolding with:

./lib/index.js https://localhost:8443 <path to client src folder> 

You may have to make lib/index.js executable in the file system. With yarn you need somewhat different commands.

Before you can run the scaffolded code you still need to Register the reducers and the routes in the client/src/index.js, see Generating.

Documentation

The documentation of API Platform Create Client can be browsed on the official website.

The extensions are documented in detail in the readmes of the corresponding react branches of Tutorial API Platform.

Features

  • Generate high-quality TypeScript or ES6 components:
    • List view
    • Creation form
    • Editing form
    • Deletion button
  • Use the Hydra or OpenAPI documentation to generate the code
  • Generate the suitable input type (number, date...) according to the type of the API property
  • Display of the server-side validation errors under the related input (if using API Platform Core)
  • Client-side validation (required attributes)
  • The generated HTML is compatible with Bootstrap and includes mandatory classes
  • The generated HTML code is accessible to people with disabilities (ARIA support)
  • Bring your own templates

Usage

Hydra

npm init @api-platform/client https://demo.api-platform.com/ output/ --resource Book

OpenAPI 3

npm init @api-platform/client https://demo.api-platform.com/docs.json output/ --resource Book --format openapi3

Credits

Created by Kévin Dunglas.

Sponsored by Les-Tilleuls.coop.

Commercial support is available upon request.

Modifications and extensions in additional branches are Copyright (c) MetaClass, Groningen, 2020.

MetaClass offers software development and support in the Netherlands for Symfony, API Platform, React.js and Next.js

About

This fork includes branches with adapted versions of React Generator based on the Tutorial API Platform.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 40.1%
  • Vue 33.1%
  • JavaScript 25.9%
  • Other 0.9%