[data views] Reenable fields_for_wildcard response schema (#160054)

## Summary

Restore fields_for_wildcard response schema validation.
This commit is contained in:
Matthew Kime 2023-06-27 22:22:39 -05:00 committed by GitHub
parent cc6e1ef591
commit a1cfc2db21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View file

@ -69,7 +69,6 @@ const fieldSubTypeSchema = schema.object({
nested: schema.maybe(schema.object({ path: schema.string() })),
});
// @ts-expect-error
const FieldDescriptorSchema = schema.object({
aggregatable: schema.boolean(),
name: schema.string(),
@ -90,6 +89,9 @@ const FieldDescriptorSchema = schema.object({
])
),
timeSeriesDimension: schema.maybe(schema.boolean()),
conflictDescriptions: schema.maybe(
schema.recordOf(schema.string(), schema.arrayOf(schema.string()))
),
});
const validate: FullValidationConfig<any, any, any> = {
@ -98,7 +100,6 @@ const validate: FullValidationConfig<any, any, any> = {
// not available to get request
body: schema.maybe(schema.object({ index_filter: schema.any() })),
},
/*
response: {
200: {
body: schema.object({
@ -107,7 +108,6 @@ const validate: FullValidationConfig<any, any, any> = {
}),
},
},
*/
};
const handler: RequestHandler<{}, IQuery, IBody> = async (context, request, response) => {
@ -188,5 +188,8 @@ export const registerFieldForWildcard = (
router.versioned.post({ path, access }).addVersion({ version, validate }, handler);
router.versioned
.get({ path, access })
.addVersion({ version, validate: { request: { query: querySchema } } }, handler);
.addVersion(
{ version, validate: { request: { query: querySchema }, response: validate.response } },
handler
);
};

View file

@ -163,4 +163,5 @@ export interface FieldDescriptorRestResponse {
timeZone?: string[];
timeSeriesMetric?: 'histogram' | 'summary' | 'counter' | 'gauge';
timeSeriesDimension?: boolean;
conflictDescriptions?: Record<string, string[]>;
}