Skip to content

Commit a91e541

Browse files
authored
Merge branch 'main' into cat-h-values-2
2 parents a10ed33 + 9e4600f commit a91e541

File tree

37 files changed

+509
-127
lines changed

37 files changed

+509
-127
lines changed

Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
SHELL := /bin/bash
22

3-
validate: ## Validate a given endpoint request or response
3+
validate: lint ## Validate a given endpoint request or response
44
@node compiler/run-validations.js --api $(api) --type $(type) --branch $(branch)
5-
@npm run lint --prefix specification
65

76
validate-no-cache: ## Validate a given endpoint request or response without local cache
87
@node compiler/run-validations.js --api $(api) --type $(type) --branch $(branch) --no-cache
@@ -86,6 +85,9 @@ generate-language-examples-with-java:
8685
@node docs/examples/generate-language-examples.js java
8786
@npm run format:fix-examples --prefix compiler
8887

88+
lint:
89+
@npm run lint --prefix specification
90+
8991
lint-docs: ## Lint the OpenAPI documents after overlays
9092
@npx @redocly/cli lint "output/openapi/elasticsearch-*.json" --config "docs/linters/redocly.yaml" --format stylish --max-problems 500
9193

@@ -95,7 +97,7 @@ lint-docs-stateful: ## Lint only the elasticsearch-openapi-docs-final.json file
9597
lint-docs-serverless: ## Lint only the serverless OpenAPI document after overlays
9698
@npx @redocly/cli lint "output/openapi/elasticsearch-serverless-openapi-docs-final.json" --config "docs/linters/redocly.yaml" --format stylish --max-problems 500
9799

98-
contrib: | generate license-check spec-format-fix transform-to-openapi filter-for-serverless lint-docs ## Pre contribution target
100+
contrib: | lint generate license-check spec-format-fix transform-to-openapi filter-for-serverless lint-docs ## Pre contribution target
99101

100102
help: ## Display help
101103
@awk 'BEGIN {FS = ":.*##"; printf "Usage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

compiler/src/model/utils.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,11 @@ export function hoistRequestAnnotations (
724724
assert(jsDocs, false, `Unhandled tag: '${tag}' with value: '${value}' on request ${request.name.name}`)
725725
}
726726
})
727+
728+
if (endpoint.availability.stack?.visibility !== 'private') {
729+
assert(jsDocs, tags.doc_id !== '' && tags.doc_id !== null && tags.doc_id !== undefined,
730+
`Request ${request.name.name} needs a @doc_id annotation`)
731+
}
727732
}
728733

729734
/** Lifts jsDoc type annotations to fixed properties on Type */

compiler/test/body-codegen-name/specification/_global/index/request.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
/**
2121
* @rest_spec_name index
2222
* @availability stack since=0.0.0 stability=stable
23+
* @doc_id docs-index
2324
*/
2425
export interface Request {
2526
body: Foo

compiler/test/duplicate-body-codegen-name/specification/_global/index/request.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
/**
2121
* @rest_spec_name index
2222
* @availability stack since=0.0.0 stability=stable
23+
* @doc_id docs-index
2324
*/
2425
export interface Request {
2526
path_parts: {

compiler/test/no-body/specification/_global/info/request.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
/**
2121
* @rest_spec_name info
2222
* @availability stack since=0.0.0 stability=stable
23+
* @doc_id api-root
2324
*/
2425
export interface Request {
2526
body: {
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
/**
21+
* @rest_spec_name index
22+
* @availability stack since=0.0.0 stability=stable
23+
*/
24+
export interface Request {
25+
body: {
26+
foo: string
27+
}
28+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"extends": "../../../../specification/tsconfig.json",
3+
"typeRoots": ["./**/*.ts"],
4+
"include": ["./**/*.ts"]
5+
}

compiler/test/no-doc-id/test.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import { join } from 'path'
21+
import test from 'ava'
22+
import Compiler from '../../src/compiler'
23+
import * as Model from '../../src/model/metamodel'
24+
25+
const specsFolder = join(__dirname, 'specification')
26+
const outputFolder = join(__dirname, 'output')
27+
28+
test("Body cannot be defined if the API methods don't allow it", t => {
29+
const compiler = new Compiler(specsFolder, outputFolder)
30+
const error = t.throws(() => compiler.generateModel())
31+
t.is(error?.message, "Request Request needs a @doc_id annotation")
32+
})

compiler/test/request-availability/specification/_global/index/request.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
* @rest_spec_name index
2222
* @availability serverless visibility=private stability=experimental
2323
* @availability stack stability=beta since=1.2.3 visibility=feature_flag feature_flag=abc
24+
* @doc_id docs-index
2425
*/
2526
export interface Request<TDocument> {
2627
path_parts: {

compiler/test/request-fields/specification/_global/index/request.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
/**
2121
* @rest_spec_name index
2222
* @availability stack stability=stable since=0.0.0
23+
* @doc_id docs-index
2324
*/
2425
export interface Request<TDocument> {
2526
path_parts: {

0 commit comments

Comments
 (0)