Skip to content

Commit

Permalink
Bug 1884613: Fix runtime error for basic users creating Prometheus in…
Browse files Browse the repository at this point in the history
…stance

Add `definitions` property to the schema returned by `definitionFor` so that `$ref` properties can be
resolved.
  • Loading branch information
TheRealJon authored and openshift-cherrypick-robot committed Oct 5, 2020
1 parent ff3bf65 commit 9b721df
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion frontend/public/module/k8s/swagger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ export const definitionFor = _.memoize((model: K8sKind): SwaggerDefinition => {
return null;
}
const key = getDefinitionKey(model, swaggerDefinitions);
return _.get(swaggerDefinitions, key);
// Some schemas might use $ref to reference an external schmema. In order for $ref to resolve,
// the referenced schema must be defined in the `definitions` property of the
// referencing schema.
return {
definitions: swaggerDefinitions,
...(swaggerDefinitions?.[key] ?? {}),
};
}, referenceForModel);

const getRef = (definition: SwaggerDefinition): string => {
Expand Down Expand Up @@ -118,6 +124,7 @@ export const getResourceDescription = _.memoize((kindObj: K8sKind): string => {
}, referenceForModel);

export type SwaggerDefinition = {
definitions?: SwaggerDefinitions;
description?: string;
type?: string;
enum?: string[];
Expand Down

0 comments on commit 9b721df

Please sign in to comment.