ShortURL: Add generate name prefix to create payload (#111854)

ShortURL: Add generate name suffix to create payload
This commit is contained in:
Ezequiel Victorero
2025-10-07 14:34:58 -03:00
committed by GitHub
parent 7fbd5441bf
commit 84a2f41016
@@ -1,3 +1,27 @@
import { generatedAPI } from './endpoints.gen';
export const shortURLAPIv1alpha1 = generatedAPI.enhanceEndpoints({});
export const shortURLAPIv1alpha1 = generatedAPI.enhanceEndpoints({
endpoints: {
createShortUrl: (endpointDefinition) => {
const originalQuery = endpointDefinition.query;
if (!originalQuery) {
return;
}
endpointDefinition.query = (requestOptions) => {
// Ensure metadata exists
if (!requestOptions.shortUrl.metadata) {
requestOptions.shortUrl.metadata = {};
}
const metadata = requestOptions.shortUrl.metadata;
if (!metadata.name && !metadata.generateName) {
// GenerateName lets the apiserver create a new uid for the name
// This wont be used, the backend will generate a random uid but cannot be blank or will fail.
metadata.generateName = 's-';
}
return originalQuery(requestOptions);
};
},
},
});