Skip to content

Merge 2.6 #1290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Feb 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9eacb5e
[Releases] Update stable and old-stable branch (#1254)
Jibbarth Jan 24, 2021
29d1b84
Improve the Getting Started Guide and update screenshots (#1258)
dunglas Jan 25, 2021
d3d93f5
Fix missing link to Doctrine ORM (#1256)
Oryss Jan 25, 2021
b89df8d
Typo in array inside PHP8 attribute (#1259)
akserikawa Jan 26, 2021
b7a4db1
added formik to required dependencies (#1260)
justinezahiri Jan 27, 2021
fe9f98e
Update subresources.md (#1262)
GrimpEreau Jan 28, 2021
78b7082
ci: switch to GitHub Actions (#1261)
dunglas Jan 28, 2021
d4c7049
Lint Markdown (#1264)
dunglas Jan 29, 2021
98a06f9
Server-side validation documentation (#1265)
alanpoulain Jan 31, 2021
ef08308
Fix messenger documentation (#1268)
soyuka Feb 2, 2021
7e28783
Fix disabling operations doc (#1269)
soyuka Feb 2, 2021
8cc9e0e
Update annotations of Serialization (#1267)
GrimpEreau Feb 2, 2021
46ea4ba
correct type in PersonHandler example (#1273)
chuckadams Feb 4, 2021
98075fc
Fixed typo's in Messenger doc (#1274)
stephanvierkant Feb 5, 2021
f4237da
change patch format to diff (#1275)
dunglas Feb 6, 2021
5886927
Update filters.md (#1271)
GrimpEreau Feb 6, 2021
e34819b
Remove unused InputGuesser (#1278)
cedriclombardot Feb 10, 2021
d097fee
No delete operations in collection (#1279)
cedriclombardot Feb 10, 2021
01083dc
Update client_items_per_page doc (#1281)
jmontoyaa Feb 12, 2021
c6c891b
Update index.md (#1282)
Selenuix Feb 12, 2021
9773011
Update OWASP input validation link (#1283)
adepreis Feb 13, 2021
ddee00d
Update "Changing Operations [...]" section (#1284)
yivi Feb 15, 2021
cb64a61
Add global resources defaults entry (#1287)
alanpoulain Feb 16, 2021
4431893
Add a note about skipping null values for JSON Merge Patch (#1289)
alanpoulain Feb 17, 2021
192fe7b
Merge branch '2.6'
alanpoulain Feb 17, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Deploy Website

on:
push:
branches:
- main
- '*.*'

jobs:
deploy:
runs-on: ubuntu-latest
steps:

- name: Checkout the website
uses: actions/checkout@v2
with:
repository: api-platform/website
ref: main

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

- name: Install deps
run: yarn install

- name: Retrieve docs
run: bin/retrieve-documentation

- name: Build website
env:
GITHUB_KEY: ${{ secrets.CONTRIBUTORS_GITHUB_TOKEN }}
run: yarn gatsby build

- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
cname: api-platform.com
38 changes: 38 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Lint

on:
- push
- pull_request

jobs:
build:
name: Lint
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Lint
uses: github/super-linter@v3
env:
VALIDATE_ALL_CODEBASE: false
VALIDATE_EDITORCONFIG: false
VALIDATE_JSCPD: false
DEFAULT_BRANCH: 2.6
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-

- name: Install Proselint
run: pip install --quiet --user proselint

- name: Run Proselint
run: find . -name '*.md' -exec proselint {} \;
4 changes: 4 additions & 0 deletions .markdownlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
MD013:
line_length: 400
no-inline-html:
allowed_elements: [a, p, img, br]
40 changes: 0 additions & 40 deletions .travis.yml

This file was deleted.

124 changes: 71 additions & 53 deletions admin/components.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion admin/customizing.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,4 +185,4 @@ For instance, using an autocomplete input is straightforward, [checkout the dedi
API Platform is built on top of [React Admin](https://marmelab.com/react-admin/).
You can use all the features provided by the underlying library with API Platform Admin, including support for [file upload](https://marmelab.com/react-admin/DataProviders.html#decorating-your-data-provider-example-of-file-upload), [authentication](https://marmelab.com/react-admin/Authentication.html), [authorization](https://marmelab.com/react-admin/Authorization.html) and deeper customization.

To learn more about these capabilities, refer to [the React Admin documentation](https://marmelab.com/react-admin/).
To learn more about these capabilities, refer to [the React Admin documentation](https://marmelab.com/react-admin/).
1 change: 0 additions & 1 deletion admin/file-upload.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
HydraAdmin,
ResourceGuesser,
CreateGuesser,
InputGuesser
} from "@api-platform/admin";
import { FileField, FileInput } from "react-admin";

Expand Down
17 changes: 13 additions & 4 deletions admin/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,21 @@ Otherwise, all you need to install API Platform Admin is a JavaScript package ma

If you don't have an existing React Application, create one using [Create React App](https://create-react-app.dev/):

$ yarn create react-app my-admin
```console
yarn create react-app my-admin
```

Go to the directory of your project:

$ cd my-admin
```console
cd my-admin
```

Finally, install the `@api-platform/admin` library:

$ yarn add @api-platform/admin
```console
yarn add @api-platform/admin
```

## Creating the Admin

Expand Down Expand Up @@ -59,7 +65,10 @@ nelmio_cors:

Clear the cache to apply this change:

$ docker-compose exec php bin/console cache:clear --env=prod
```console
docker-compose exec php \
bin/console cache:clear --env=prod
```

Your new administration interface is ready! Type `yarn start` to try it!

Expand Down
Binary file added admin/images/required-field.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added admin/images/submission-error-field.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions admin/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ API Platform Admin is a tool to automatically create a beautiful and fully featu
for any API supporting [the Hydra Core Vocabulary](http://www.hydra-cg.com/) or other API specification formats supported by [`@api-platform/api-doc-parser`](https://github.com/api-platform/api-doc-parser) (experimental support for [OpenAPI](https://www.openapis.org/) is also available).

API Platform Admin is the perfect companion of APIs created
using [the API Platform framework](https://api-platform.com), but also supports APIs written with any other programming language or framework as long as they expose a standard Hydra API documentation.
using [the API Platform framework](https://api-platform.com), but also supports APIs written with any other programming language or framework as long as they expose a standard Hydra API documentation.

API Platform Admin is a 100% standalone Single-Page-Application with no coupling to the server part,
according to the API-first paradigm.

API Platform Admin parses the API documentation then uses the awesome [React Admin](https://marmelab.com/react-admin/)
library to expose a nice, responsive, management interface (Create-Retrieve-Update-Delete) for all documented resource types.

You can **customize everything** by using provided React Admin and [Material UI](https://material-ui.com/) components, or by writing your custom [React](https://reactjs.org/) components.
You can **customize everything** by using provided React Admin and [Material UI](https://material-ui.com/) components, or by writing your custom [React](https://reactjs.org/) components.

## Features

* Automatically generates an admin interface for all the resources of the API thanks to hypermedia features of Hydra
* Generates 'list', 'create', 'show', and 'edit' screens, as well as a delete button
* Generates suitable inputs and fields according to the API doc (e.g. number HTML input for numbers, checkbox for booleans, selectbox for relationships...)
* Generates suitable inputs and fields according to Schema.org types if available (e.g. email field for http://schema.org/email)
* Generates suitable inputs and fields according to Schema.org types if available (e.g. email field for `http://schema.org/email`)
* Handles relationships
* Supports pagination
* Supports filters and ordering
Expand Down
68 changes: 68 additions & 0 deletions admin/validation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Validation

API Platform Admin manages automatically two types of validation: client-side validation and server-side (or submission) validation.

## Client-side Validation

If the API documentation indicates that a field is mandatory,
API Platform Admin will automatically add a [required client-side validation](https://marmelab.com/react-admin/CreateEdit.html#per-input-validation-built-in-field-validators).

For instance, with API Platform Core as backend, if you write the following:

```php
<?php
// api/src/Entity/Book.php

use ApiPlatform\Core\Annotation\ApiResource;
use Symfony\Component\Validator\Constraints as Assert;

/**
* @ApiResource
*/
class Book
{
/**
* @Assert\NotBlank
*/
public ?string $title = null;
}
```

If you create a new book and touch the "Title" field without typing, you will see:

![Required title field](images/required-field.png)

## Server-side Validation

When the form is submitted and if submission errors are received,
API Platform Admin will automatically show the errors for the corresponding fields.

To do so, it uses the [submission validation](https://marmelab.com/react-admin/CreateEdit.html#submission-validation) feature of React Admin,
and the mapping between the response and the fields is done by the [schema analyzer](components.md#schemaanalyzer) with its method `getSubmissionErrors`.

API Platform Core is supported by default, but if you use another backend, you will need to override the `getSubmissionErrors` method.

For example if you have this code:

```php
<?php
// api/src/Entity/Book.php

use ApiPlatform\Core\Annotation\ApiResource;
use Symfony\Component\Validator\Constraints as Assert;

/**
* @ApiResource
*/
class Book
{
/**
* @Assert\Isbn
*/
public ?string $isbn = null;
}
```

If you submit the form with an invalid ISBN, you will see:

![Submission error field](images/submission-error-field.png)
2 changes: 1 addition & 1 deletion client-generator/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Client Generator is the fastest way to scaffold fully featured webapps and nativ

![Screencast](images/client-generator-demo.gif)

*Generated React and React Native apps, updated in real time*
## Generated React and React Native Apps, Updated in Real Time

It is able to generate apps using the following frontend stacks:

Expand Down
6 changes: 3 additions & 3 deletions client-generator/nextjs.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ Create a [Next.js application with express server](https://github.com/zeit/next.

Enable TypeScript in your next project

$ yarn add --dev typescript @types/react @types/node
yarn add --dev typescript @types/react @types/node

Install required dependencies:

$ yarn add lodash.get lodash.has @types/lodash isomorphic-unfetch
yarn add lodash.get lodash.has @types/lodash isomorphic-unfetch formik

## Generating Routes

Expand All @@ -35,7 +35,7 @@ Install required dependencies:

You can launch the server with

$ yarn dev
yarn dev

Go to `http://localhost:3000/books/` to start using your app.

Expand Down
39 changes: 26 additions & 13 deletions client-generator/nuxtjs.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@ The Nuxt.js Client Generator generates components for Server Side Rendered appli

Create a [Nuxt.js application](https://nuxtjs.org/guides/get-started/installation#using-create-nuxt-app). The easiest way is to execute:

$ npx create-nuxt-app your-app-name
# or
$ yarn create nuxt-app your-app-name
```console
npx create-nuxt-app your-app-name
```

It will ask you some questions you can use these answers :
or:

```console
yarn create nuxt-app your-app-name
```

It will ask you some questions you can use these answers :

```console
Project name: your-app-name
Programming language: JavaScript
Package manager: Yarn
Expand All @@ -30,8 +36,10 @@ Deployment target: Static (Static/JAMStack hosting)

Install required dependencies:

$ yarn add moment lodash vue-i18n vuelidate vuex-map-fields nuxt-i18n
# yarn add --dev @nuxtjs/vuetify @nuxtjs/fontawesome
```console
yarn add moment lodash vue-i18n vuelidate vuex-map-fields nuxt-i18n
yarn add --dev @nuxtjs/vuetify @nuxtjs/fontawesome
```

## Updating nuxtjs config

Expand All @@ -48,19 +56,22 @@ Update your `nuxt.config.js` with following:
// to avoid name conflicts in generators
components: false,
```

## Generating Routes

$ npx @api-platform/client-generator https://demo.api-platform.com . --generator nuxt
# Replace the URL by the entrypoint of your Hydra-enabled API
```console
npx @api-platform/client-generator https://demo.api-platform.com . --generator nuxt
```

> Note: Omit the resource flag to generate files for all resource types exposed by the API.
Replace the URL by the entrypoint of your Hydra-enabled API

## Updating default layout
**Note:** Omit the resource flag to generate files for all resource types exposed by the API.

## Updating default layout

Update your `layouts/default.vue` with following:

```javascript
```vue
<template>
<v-app>
<alert />
Expand Down Expand Up @@ -132,9 +143,11 @@ export default {

## Starting the Project

You can launch the server with
You can launch the server with:

$ yarn dev
```console
yarn dev
````

Go to `https://localhost:3000/books/` to start using your app.

Expand Down
Loading