Skip to content

Commit f4a946e

Browse files
committed
Create endpoint in hoistRequestAnnotations directly
1 parent a46d7be commit f4a946e

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

compiler/src/model/utils.ts

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -628,23 +628,6 @@ function setTags<TType extends model.BaseType | model.Property | model.EnumMembe
628628
}
629629
}
630630

631-
export function updateEndpoints (mappings: Record<string, model.Endpoint>, name: string): model.Endpoint {
632-
mappings[name] = {
633-
name: name,
634-
// @ts-expect-error TODO
635-
description: null,
636-
// @ts-expect-error TODO
637-
docUrl: null,
638-
request: null,
639-
requestBodyRequired: false,
640-
response: null,
641-
urls: []
642-
}
643-
mappings[name].availability = {}
644-
645-
return mappings[name]
646-
}
647-
648631
/** Lifts jsDoc type annotations to request properties */
649632
export function hoistRequestAnnotations (
650633
request: model.Request, jsDocs: JSDoc[], mappings: Record<string, model.Endpoint>, response: model.TypeName | null
@@ -667,9 +650,19 @@ export function hoistRequestAnnotations (
667650
assert(jsDocs, apiName !== '' && apiName !== null && apiName !== undefined,
668651
`Request ${request.name.name} does not declare the @rest_spec_name to link back to`)
669652

670-
const endpoint = updateEndpoints(mappings, apiName)
671-
endpoint.request = request.name
672-
endpoint.response = response
653+
const endpoint: model.Endpoint = {
654+
name: apiName,
655+
// @ts-expect-error this will be filled in SetTags below
656+
description: null,
657+
// @ts-expect-error this will be filled in SetTags below
658+
docUrl: null,
659+
request: request.name,
660+
requestBodyRequired: false,
661+
response: response,
662+
urls: [],
663+
availability: {}
664+
}
665+
mappings[apiName] = endpoint
673666

674667
// This ensures the tags from request end up on the endpoint
675668
setTags(jsDocs, request, tags, knownRequestAnnotations, (tags, tag, value) => {

0 commit comments

Comments
 (0)