Signed-off-by: kevspl <kkantesaria@splunk.com>
This commit is contained in:
kevspl
2024-12-02 17:20:51 -05:00
parent 83e7780ca4
commit afcebeacf4
4 changed files with 23 additions and 14 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/backend-openapi-utils': minor
---
Fixed a Typescript error when trying to use the new OpenAPI server-side generated code.
+1 -1
View File
@@ -30,7 +30,7 @@ export type {
CookieParameters,
PathParameters,
} from './utility';
export type { ApiRouter } from './router';
export type { ApiRouter, TypedRouter } from './router';
export type { PathTemplate } from './types/common';
export { wrapInOpenApiTestServer, wrapServer } from './testUtils';
export {
+17 -1
View File
@@ -14,7 +14,12 @@
* limitations under the License.
*/
import { Router } from 'express';
import { DocRequestMatcher, RequiredDoc } from './types';
import {
DocRequestMatcher,
EndpointMap,
EndpointMapRequestMatcher,
RequiredDoc,
} from './types';
/**
* Typed Express router based on an OpenAPI 3.1 spec.
@@ -37,3 +42,14 @@ export interface ApiRouter<Doc extends RequiredDoc> extends Router {
head: DocRequestMatcher<Doc, this, 'head'>;
}
/**
* @public
*/
export interface TypedRouter<GeneratedEndpointMap extends EndpointMap>
extends Router {
get: EndpointMapRequestMatcher<GeneratedEndpointMap, this, 'get'>;
post: EndpointMapRequestMatcher<GeneratedEndpointMap, this, 'post'>;
put: EndpointMapRequestMatcher<GeneratedEndpointMap, this, 'put'>;
delete: EndpointMapRequestMatcher<GeneratedEndpointMap, this, '_delete'>;
}
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Router } from 'express';
import type core from 'express-serve-static-core';
import { PathTemplate, ValueOf } from './common';
@@ -209,14 +208,3 @@ export interface EndpointMapRequestMatcher<
>
): T;
}
/**
* @public
*/
export interface TypedRouter<GeneratedEndpointMap extends EndpointMap>
extends Router {
get: EndpointMapRequestMatcher<GeneratedEndpointMap, this, 'get'>;
post: EndpointMapRequestMatcher<GeneratedEndpointMap, this, 'post'>;
put: EndpointMapRequestMatcher<GeneratedEndpointMap, this, 'put'>;
delete: EndpointMapRequestMatcher<GeneratedEndpointMap, this, '_delete'>;
}