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 5 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
119 changes: 119 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,125 @@ 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 API Controller
MarGraz marked this conversation as resolved.
Show resolved Hide resolved

The `OrchardCore.Contents` module provides an `ApiController.cs` (here the ApiController [source file](https://github.com/OrchardCMS/OrchardCore/blob/main/src/OrchardCore.Modules/OrchardCore.Contents/Controllers/ApiController.cs)) featuring endpoints to manage _content items_ created in the Orchard Core "Admin" backoffice. These endpoints allow for operations such as retrieving, creating, updating, and deleting content items instances. Access to these endpoints requires authentication and appropriate user role permissions.
MarGraz marked this conversation as resolved.
Show resolved Hide resolved
MarGraz marked this conversation as resolved.
Show resolved Hide resolved
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. This requires activating the "OpenId Authorization Server" feature and configuring it (detailed information can be found in the [documentation](https://docs.orchardcore.net/en/main/docs/reference/modules/OpenId/#authorization-server)). Furthermore, the "OpenId Token Validation" feature needs to be activated, which provides a token to authenticated users for future API calls (more details are available in the [documentation](https://docs.orchardcore.net/en/main/docs/reference/modules/OpenId/#token-validation)). Upon activating these features, the administration area's "Security" section will display a new menu option "OpenID Connect," enabling the OAuth 2 server configuration through the creation of "Scopes" and "Applications".
Piedone marked this conversation as resolved.
Show resolved Hide resolved
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.
MarGraz marked this conversation as resolved.
Show resolved Hide resolved

### 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 | | Yes | string |
MarGraz marked this conversation as resolved.
Show resolved Hide resolved
Piedone 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
MarGraz marked this conversation as resolved.
Show resolved Hide resolved

| Name | Located in | Description | Required | Schema |
| ---- | ---------- | ----------- | -------- | ---- |
| name | path | | Yes | string |
| parameters | query | | No | string |

##### 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 |
| ---- | ---------- | ----------- | -------- | ---- |
| draft | query | | No | boolean |

##### 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"
}
```

##### 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 | | Yes | string |
| parameters | query | | No | string |

##### 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 | | Yes | string |

##### Responses

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

## GraphQL

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