Skip to content

Commit ebd1f25

Browse files
committed
Add doc_tag
1 parent aefa7a7 commit ebd1f25

File tree

8 files changed

+12
-4
lines changed

8 files changed

+12
-4
lines changed

compiler-rs/clients_schema/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,9 @@ pub struct Endpoint {
815815
#[serde(skip_serializing_if = "Option::is_none")]
816816
pub availability: Option<Availabilities>,
817817

818+
#[serde(skip_serializing_if = "Option::is_none")]
819+
pub doc_tag: Option<String>,
820+
818821
/// If missing, there is not yet a request definition for this endpoint.
819822
#[serde(skip_serializing_if = "Option::is_none")]
820823
pub request: Option<TypeName>,

compiler-rs/clients_schema_to_openapi/src/paths.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ pub fn add_endpoint(
196196

197197
// Create the operation, it will be repeated if we have several methods
198198
let operation = openapiv3::Operation {
199-
tags: vec![namespace.to_string()],
199+
tags: if endpoint.doc_tag.is_some() {vec![endpoint.doc_tag.clone().expect("TODO: panic message")]} else {vec![namespace.to_string()]},
200200
summary: sum_desc.summary,
201201
description: sum_desc.description,
202202
// external_docs: tac.convert_external_docs(endpoint),

compiler-rs/clients_schema_to_openapi/src/schemas.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const SCHEMA_PLACEHOLDER: ReferenceOr<Schema> = ReferenceOr::Reference {
3838
/// Convert `schema.json` type and value definitions to OpenAPI schemas:
3939
///
4040
/// The `convert_*` functions return a concrete schema and not a reference and do not store them in
41-
/// the OpenAPI `components.schema`. This is the role of `for_type_name` hat creates and stores the
41+
/// the OpenAPI `components.schema`. This is the role of `for_type_name` that creates and stores the
4242
/// schema and returns a reference.
4343
impl<'a> TypesAndComponents<'a> {
4444
/// Convert a value. Returns a schema reference and not a concrete schema, as values can
727 Bytes
Binary file not shown.

compiler/src/model/build-model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export function compileEndpoints (): Record<string, model.Endpoint> {
6767
name: api,
6868
description: spec.documentation.description,
6969
docUrl: spec.documentation.url,
70+
docTag: spec.docTag,
7071
// Setting these values by default should be removed
7172
// when we no longer use rest-api-spec stubs as the
7273
// source of truth for stability/visibility.

compiler/src/model/json-spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export interface JsonSpec {
6161
description: string
6262
required?: boolean
6363
}
64+
docTag?: string
6465
}
6566

6667
export default function buildJsonSpec (): Map<string, JsonSpec> {

compiler/src/model/metamodel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ export class Endpoint {
408408
docId?: string
409409
deprecation?: Deprecation
410410
availability: Availabilities
411-
411+
docTag?: string
412412
/**
413413
* If the request value is `null` it means that there is not yet a
414414
* request type definition for this endpoint.

compiler/src/model/utils.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ export function hoistRequestAnnotations (
625625
request: model.Request, jsDocs: JSDoc[], mappings: Record<string, model.Endpoint>, response: model.TypeName | null
626626
): void {
627627
const knownRequestAnnotations = [
628-
'rest_spec_name', 'behavior', 'class_serializer', 'index_privileges', 'cluster_privileges', 'doc_id', 'availability'
628+
'rest_spec_name', 'behavior', 'class_serializer', 'index_privileges', 'cluster_privileges', 'doc_id', 'availability', 'doc_tag'
629629
]
630630
// in most of the cases the jsDocs comes in a single block,
631631
// but it can happen that the user defines multiple single line jsDoc.
@@ -696,6 +696,9 @@ export function hoistRequestAnnotations (
696696
for (const [availabilityName, availabilityValue] of Object.entries(availabilities)) {
697697
endpoint.availability[availabilityName] = availabilityValue
698698
}
699+
} else if (tag === 'doc_tag') {
700+
assert(jsDocs, value.trim() !== '', `Request ${request.name.name}'s @doc_tag cannot be empty`)
701+
endpoint.docTag = value.trim()
699702
} else {
700703
assert(jsDocs, false, `Unhandled tag: '${tag}' with value: '${value}' on request ${request.name.name}`)
701704
}

0 commit comments

Comments
 (0)