Skip to content
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

Adding Content Item ApiController.cs endpoints documentation #15512

Merged
merged 36 commits into from
May 6, 2024
Merged
Changes from 16 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
bf9a520
Update README.md Adding Api Controller infos
MarGraz Mar 13, 2024
0d7dc81
Added endpoints details
MarGraz Mar 14, 2024
ba69e72
Added more details in the endpoints parameters
MarGraz Mar 14, 2024
aea7105
Added some division lines
MarGraz Mar 14, 2024
baecb57
Minor changes
MarGraz Mar 14, 2024
dbd1544
Update src/docs/reference/modules/Contents/README.md
MarGraz Apr 25, 2024
8fd2d9d
Update src/docs/reference/modules/Contents/README.md
MarGraz Apr 25, 2024
4a4b6ca
Update src/docs/reference/modules/Contents/README.md
MarGraz Apr 25, 2024
57e7aaa
Update src/docs/reference/modules/Contents/README.md
MarGraz Apr 25, 2024
c07a19d
Update src/docs/reference/modules/Contents/README.md
MarGraz Apr 25, 2024
701e3ce
Merge branch 'main' into patch-7
MarGraz Apr 25, 2024
bf0867c
Update README.md
MarGraz Apr 25, 2024
73104f5
Update README.md
MarGraz Apr 25, 2024
3074ab1
Update README.md
MarGraz Apr 25, 2024
49ef0f3
Update README.md
MarGraz Apr 25, 2024
39ac855
Merge branch 'main' into patch-7
Piedone May 1, 2024
cd666fa
Update src/docs/reference/modules/Contents/README.md
MarGraz May 2, 2024
a32549e
Update src/docs/reference/modules/Contents/README.md
MarGraz May 2, 2024
104e123
Update src/docs/reference/modules/Contents/README.md
MarGraz May 2, 2024
9afa5d9
Update src/docs/reference/modules/Contents/README.md
MarGraz May 2, 2024
97f2412
Update src/docs/reference/modules/Contents/README.md
MarGraz May 2, 2024
a634eef
Update src/docs/reference/modules/Contents/README.md
MarGraz May 2, 2024
9902943
Update src/docs/reference/modules/Contents/README.md
MarGraz May 2, 2024
e964aae
Update src/docs/reference/modules/Contents/README.md
MarGraz May 2, 2024
a7db874
Update src/docs/reference/modules/Contents/README.md
MarGraz May 2, 2024
d5c4472
Update README.md remove span tags
MarGraz May 2, 2024
f1a96f6
Removed "queries" endpoint infos
MarGraz May 2, 2024
1d1fc82
Chenged the link to the GraphQL module, in the "Useful modules and li…
MarGraz May 2, 2024
47c32e5
Used relative path, instead of absolute path
MarGraz May 2, 2024
a18da9a
Minor changes to the grammar
MarGraz May 2, 2024
da34ccf
Changes to README.md updated terminology to minimal API
MarGraz May 6, 2024
50fc608
Update README.md fixed incorrect absolute path in a link
MarGraz May 6, 2024
f57373a
Merge branch 'main' into patch-7
hishamco May 6, 2024
0012e97
Update src/docs/reference/modules/Contents/README.md
MarGraz May 6, 2024
fc933ff
Update src/docs/reference/modules/Contents/README.md
MarGraz May 6, 2024
d14ce56
Merge branch 'main' into patch-7
hishamco May 6, 2024
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
130 changes: 130 additions & 0 deletions src/docs/reference/modules/Contents/README.md
MarGraz marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,136 @@ Well known properties include
To log shapes call `@Orchard.ConsoleLog(Model.Content as object)` after calling `@await DisplayAsync(Model.Content)`
This will allow the shape to execute, and populate the alternates for any child shapes.

## Contents Module RESTful Web API

The `OrchardCore.Contents` module provides RESTful API endpoints via [`ApiController`](https://github.com/OrchardCMS/OrchardCore/blob/main/src/OrchardCore.Modules/OrchardCore.Contents/Controllers/ApiController.cs) featuring endpoints to manage _content items_. These endpoints allow for operations such as retrieving, creating, updating, and deleting single content item instances. Access to these endpoints requires authentication and appropriate user role permissions.
Piedone marked this conversation as resolved.
Show resolved Hide resolved

### Useful modules and libraries

1. We suggest to use the docs about the [GraphQL module](https://docs.orchardcore.net/en/main/docs/reference/modules/Apis.GraphQL/), to be used for querying content items.
Piedone marked this conversation as resolved.
Show resolved Hide resolved
2. There's a [Swagger module](https://github.com/OrchardCoreContrib/OrchardCoreContrib.Modules/blob/main/src/OrchardCoreContrib.Apis.Swagger/README.md) made by the community and allows you to create APIs documentations using Swagger.
3. Lombiq provide [client library](https://github.com/Lombiq/Orchard-Core-API-Client) for communicating with the Orchard Core web APIs.
MarGraz marked this conversation as resolved.
Show resolved Hide resolved

### Activating the "OpenId Authorization Server" and "OpenId Token Validation" Features, and setting User Roles

To utilize the Orchard Core ApiController endpoints, user accounts must authenticate using the OAuth 2 standard by activating and configuring the "OpenId Authorization Server" and "OpenId Token Validation" features. Detailed configuration steps can be found in the [OpenId Authorization Server documentation](https://docs.orchardcore.net/en/main/docs/reference/modules/OpenId/#authorization-server) and the [OpenId Token Validation documentation](https://docs.orchardcore.net/en/main/docs/reference/modules/OpenId/#token-validation).
MarGraz marked this conversation as resolved.
Show resolved Hide resolved

It is usually better to create a dedicated user for performing API calls, to maintain control over user rights, and to easily activate/deactivate the API user. The `OrchardCore.OpenId` feature allows setting these user role permissions from "Roles > Edit (User)":
MarGraz marked this conversation as resolved.
Show resolved Hide resolved

- View and edit the OpenID Connect client settings
- View and edit the OpenID Connect server settings
- View and edit the OpenID Connect validation settings
- View, add, edit, and remove the OpenID Connect applications
- View, add, edit, and remove the OpenID Connect scopes

### Contents API Controller Endpoints

#### <span style="color:blue">GET /api/content/{contentItemId} </span>
MarGraz marked this conversation as resolved.
Show resolved Hide resolved
Piedone marked this conversation as resolved.
Show resolved Hide resolved

##### Parameters

| Name | Located in | Description | Required | Schema |
| ---- | ---------- | ----------- | -------- | ---- |
| contentItemId | path | The ID of the Content Item to be retrieved | Yes | string |
MarGraz marked this conversation as resolved.
Show resolved Hide resolved

##### Responses

| Code | Description |
| ---- | ----------- |
| 200 | Success |
MarGraz marked this conversation as resolved.
Show resolved Hide resolved

***

#### <span style="color:blue">GET /api/queries/{name} </span>
Piedone marked this conversation as resolved.
Show resolved Hide resolved
MarGraz marked this conversation as resolved.
Show resolved Hide resolved

##### Parameters

!!! note
This endpoint can only be used when the GraphQL feature is active.

| Name | Located in | Description | Required | Schema |
| ---- | ---------- | ----------- | -------- | ---- |
| name | path | The name of the query available in the Query panel | Yes | string |
MarGraz marked this conversation as resolved.
Show resolved Hide resolved

##### Responses

| Code | Description |
| ---- | ----------- |
| 200 | Success |

***

#### <span style="color:green">POST /api/content </span>
MarGraz marked this conversation as resolved.
Show resolved Hide resolved

##### Parameters

| Name | Located in | Description | Required | Schema |
| ---- | ---------- | ----------- | -------- | ---- |
| | payload | The content item model to be updated | Yes | Json |

##### Body payload example
MarGraz marked this conversation as resolved.
Show resolved Hide resolved

```json
{
"contentItem": "string",
"id": 0,
"contentItemId": "string",
"contentItemVersionId": "string",
"contentType": "string",
"published": true,
"latest": true,
"modifiedUtc": "2024-03-14T11:40:20.331Z",
"publishedUtc": "2024-03-14T11:40:20.331Z",
"createdUtc": "2024-03-14T11:40:20.331Z",
"owner": "string",
"author": "string",
"displayText": "string"
}
```

> This payload example model was obtained using the GraphiQL, panel available in the Admin backoffice: _Configuration_ > _GraphiQL_. In this [video](https://www.youtube.com/watch?v=8SbW3TLNhF0) you can find an overview on how to use GraphiQL.
MarGraz marked this conversation as resolved.
Show resolved Hide resolved

##### Responses

| Code | Description |
| ---- | ----------- |
| 200 | Success |

***

#### <span style="color:green">POST /api/queries/{name} </span>
MarGraz marked this conversation as resolved.
Show resolved Hide resolved

##### Parameters

!!! note
This endpoint can only be used when the GraphQL feature is active
MarGraz marked this conversation as resolved.
Show resolved Hide resolved

| Name | Located in | Description | Required | Schema |
| ---- | ---------- | ----------- | -------- | ---- |
| name | path | The name of the query available in the Query panel | Yes | string |
MarGraz marked this conversation as resolved.
Show resolved Hide resolved

##### Responses

| Code | Description |
| ---- | ----------- |
| 200 | Success |

***

#### <span style="color:red">DELETE /api/content/{contentItemId}</span>
MarGraz marked this conversation as resolved.
Show resolved Hide resolved

##### Parameters

| Name | Located in | Description | Required | Schema |
| ---- | ---------- | ----------- | -------- | ---- |
| contentItemId | path | The ID of the Content Item to be deleted | Yes | string |
MarGraz marked this conversation as resolved.
Show resolved Hide resolved

##### Responses

| Code | Description |
| ---- | ----------- |
| 200 | Success |

## GraphQL

The contents module provides a feature to provide GraphQL queries for content items.
Expand Down