Skip to content

Update the schema for the REST API specification #42346

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 2 commits into from
Aug 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
{
"scripts_painless_context": {
"stability": "experimental",
"methods": ["GET"],
"url": {
"paths": ["/_scripts/painless/_context"],
"parts": {
},
"params": {
"context" : {
"type" : "string",
"description" : "Select a specific context to retrieve API information about"
"paths": [
{
"path": "/_scripts/painless/_context",
"methods": ["GET"],
"parts": {}
}
]
},
"params": {
"context" : {
"type" : "string",
"description" : "Select a specific context to retrieve API information about"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
{
"cat.example": {
"documentation": "",
"documentation": {
"url": "https://www.elastic.co/guide/en/elasticsearch/plugins/current/plugin-authors.html",
"description": "Example"
},
"stability" : "stable",
"methods": ["GET"],
"url": {
"paths": ["/_cat/example"],
"parts": {},
"params": {
"help": {
"type": "boolean",
"description": "Return help information",
"default": false
},
"v": {
"type": "boolean",
"description": "Verbose mode. Display column headers",
"default": true
},
"message": {
"type": "string",
"description": "A simple message that will be printed out in the response",
"default": "Hello from Cat Example action"
"paths": [
{
"path" : "/_cat/example",
"methods" : ["GET"]
}
]
},
"params": {
"help": {
"type": "boolean",
"description": "Return help information",
"default": false
},
"v": {
"type": "boolean",
"description": "Verbose mode. Display column headers",
"default": true
},
"message": {
"type": "string",
"description": "A simple message that will be printed out in the response",
"default": "Hello from Cat Example action"
}
},
"body": null
Expand Down
101 changes: 56 additions & 45 deletions rest-api-spec/README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,28 @@ Example for the ["Create Index"](http://www.elastic.co/guide/en/elasticsearch/re
```json
{
"indices.create": {
"documentation": "http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-create-index.html",
"documentation":{
"url":"http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-create-index.html"
},
"stability": "stable",
"methods": ["PUT", "POST"],
"url": {
"paths": ["/{index}"],
"parts": {
"index": {
"type" : "string",
"required" : true,
"description" : "The name of the index"
}
},
"params": {
"timeout": {
"type" : "time",
"description" : "Explicit operation timeout"
"url":{
"paths":[
{
"path":"/{index}",
"method":"PUT",
"parts":{
"index":{
"type":"string",
"description":"The name of the index"
}
}
}
]
},
"params": {
"timeout": {
"type" : "time",
"description" : "Explicit operation timeout"
}
},
"body": {
Expand All @@ -38,17 +43,17 @@ Example for the ["Create Index"](http://www.elastic.co/guide/en/elasticsearch/re
The specification contains:

* The _name_ of the API (`indices.create`), which usually corresponds to the client calls
* Link to the documentation at <http://elastic.co>
* Link to the documentation at the <http://elastic.co> website
* `stability` indicating the state of the API, has to be declared explicitly or YAML tests will fail
* `experimental` highly likely to break in the near future (minor/path), no bwc guarantees.
* `experimental` highly likely to break in the near future (minor/path), no bwc guarantees.
Possibly removed in the future.
* `beta` less likely to break or be removed but still reserve the right to do so
* `stable` No backwards breaking changes in a minor
* List of HTTP methods for the endpoint
* URL specification: path, parts, parameters
* Whether body is allowed for the endpoint or not and its description
* `stable` No backwards breaking changes in a minor
* Request URL: HTTP method, path and parts
* Request parameters
* Request body specification

**NOTE**
**NOTE**
If an API is stable but it response should be treated as an arbitrary map of key values please notate this as followed

```json
Expand All @@ -62,28 +67,23 @@ If an API is stable but it response should be treated as an arbitrary map of key
}
```

## Backwards compatibility

The `methods` and `url.paths` elements list all possible HTTP methods and URLs for the endpoint;
it is the responsibility of the developer to use this information for a sensible API on the target platform.

## Backwards compatibility
The specification follows the same backward compatibility guarantees as Elasticsearch.

The specification follows the same backward compatibility guarantees as Elasticsearch.

- Within a Major, additions only.
- If an item has been documented wrong it should be deprecated instead as removing these might break downstream clients.
- Within a Major, additions only.
- If an item has been documented wrong it should be deprecated instead as removing these might break downstream clients.
- Major version change, may deprecate pieces or simply remove them given enough deprecation time.

## Deprecations

The spec allows for deprecations of:
The specification schema allows to codify API deprecations, either for an entire API, or for specific parts of the API, such as paths or parameters.

#### Entire API:

```json
{
"api" : {
"documentation": "...",
"deprecated" : {
"version" : "7.0.0",
"description" : "Reason API is being deprecated"
Expand All @@ -92,36 +92,47 @@ The spec allows for deprecations of:
}
```

#### Specific paths:
#### Specific paths and their parts:

```json
{
"api": {
"documentation": "",
"url": {
"paths": ["/_monitoring/bulk"],
"deprecated_paths" : [
"paths": [
{
"version" : "7.0.0",
"path" : "/_monitoring/{type}/bulk",
"description" : "Specifying types in urls has been deprecated"
"path":"/{index}/{type}/{id}/_create",
"method":"PUT",
"parts":{
"id":{
"type":"string",
"description":"Document ID"
},
"index":{
"type":"string",
"description":"The name of the index"
},
"type":{
"type":"string",
"description":"The type of the document",
"deprecated":true
}
},
"deprecated":{
"version":"7.0.0",
"description":"Specifying types in urls has been deprecated"
}
}
]
}
}
}
```

Here `paths` describes the preferred paths and `deprecated_paths` indicates `paths` that will still work but are now
deprecated.

#### Parameters
#### Parameters

```json
{
"api": {
"documentation": "",
"methods": ["GET"],
"url": {
"params": {
"stored_fields": {
Expand Down
144 changes: 89 additions & 55 deletions rest-api-spec/src/main/resources/rest-api-spec/api/bulk.json
Original file line number Diff line number Diff line change
@@ -1,64 +1,98 @@
{
"bulk": {
"documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-bulk.html",
"stability": "stable",
"methods": ["POST", "PUT"],
"url": {
"paths": ["/_bulk", "/{index}/_bulk", "/{index}/{type}/_bulk"],
"parts": {
"index": {
"type" : "string",
"description" : "Default index for items which don't provide one"
},
"type": {
"type" : "string",
"description" : "Default document type for items which don't provide one"
}
},
"params": {
"wait_for_active_shards": {
"type" : "string",
"description" : "Sets the number of shard copies that must be active before proceeding with the bulk operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)"
},
"refresh": {
"type" : "enum",
"options": ["true", "false", "wait_for"],
"description" : "If `true` then refresh the effected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes."
},
"routing": {
"type" : "string",
"description" : "Specific routing value"
},
"timeout": {
"type" : "time",
"description" : "Explicit operation timeout"
},
"type": {
"type" : "string",
"description" : "Default document type for items which don't provide one"
},
"_source": {
"type" : "list",
"description" : "True or false to return the _source field or not, or default list of fields to return, can be overridden on each sub-request"
},
"_source_excludes": {
"type" : "list",
"description" : "Default list of fields to exclude from the returned _source field, can be overridden on each sub-request"
"bulk":{
"documentation":{
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-bulk.html",
"description":"Allows to perform multiple index/update/delete operations in a single request."
},
"stability":"stable",
"url":{
"paths":[
{
"path":"/_bulk",
"methods":[
"POST",
"PUT"
]
},
"_source_includes": {
"type" : "list",
"description" : "Default list of fields to extract and return from the _source field, can be overridden on each sub-request"
{
"path":"/{index}/_bulk",
"methods":[
"POST",
"PUT"
],
"parts":{
"index":{
"type":"string",
"description":"Default index for items which don't provide one"
}
}
},
"pipeline" : {
"type" : "string",
"description" : "The pipeline id to preprocess incoming documents with"
{
"path":"/{index}/{type}/_bulk",
"methods":[
"POST",
"PUT"
],
"parts":{
"index":{
"type":"string",
"description":"Default index for items which don't provide one"
},
"type":{
"type":"string",
"description":"Default document type for items which don't provide one"
}
}
}
]
},
"params":{
"wait_for_active_shards":{
"type":"string",
"description":"Sets the number of shard copies that must be active before proceeding with the bulk operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)"
},
"refresh":{
"type":"enum",
"options":[
"true",
"false",
"wait_for"
],
"description":"If `true` then refresh the effected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes."
},
"routing":{
"type":"string",
"description":"Specific routing value"
},
"timeout":{
"type":"time",
"description":"Explicit operation timeout"
},
"type":{
"type":"string",
"description":"Default document type for items which don't provide one"
},
"_source":{
"type":"list",
"description":"True or false to return the _source field or not, or default list of fields to return, can be overridden on each sub-request"
},
"_source_excludes":{
"type":"list",
"description":"Default list of fields to exclude from the returned _source field, can be overridden on each sub-request"
},
"_source_includes":{
"type":"list",
"description":"Default list of fields to extract and return from the _source field, can be overridden on each sub-request"
},
"pipeline":{
"type":"string",
"description":"The pipeline id to preprocess incoming documents with"
}
},
"body": {
"description" : "The operation definition and data (action-data pairs), separated by newlines",
"required" : true,
"serialize" : "bulk"
"body":{
"description":"The operation definition and data (action-data pairs), separated by newlines",
"required":true,
"serialize":"bulk"
}
}
}
Loading