Skip to content

Commit

Permalink
handle optional query params with defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
sepbot committed Oct 6, 2024
1 parent 09fbf89 commit 8b3dcde
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
17 changes: 13 additions & 4 deletions generator/fixes.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,21 @@ export function applyFixes(schema) {

// if an input type has a default value on the docker backend
// then we want the option to omit it completely
if (
schema.definitions[definition].properties[property].default ||
schema.definitions[definition].properties[property].default === false
) {
if (schema.definitions[definition].properties[property].hasOwnProperty("default")) {
schema.definitions[definition].properties[property].default = undefined;
}
}
}

for (const path in schema.paths) {
for (const endpoint in schema.paths[path]) {
if (schema.paths[path][endpoint].parameters) {
for (const param of schema.paths[path][endpoint].parameters) {
if (param.hasOwnProperty("default")) {
param.default = undefined;
}
}
}
}
}
}
1 change: 0 additions & 1 deletion tests/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ test("DockerClient", async () => {
// TODO: this returns transfer-encoding chunked
await client.Image.Create({
query: {
platform: "", // TODO: fix defaults in query params
fromImage: "hello-world",
tag: "latest",
},
Expand Down

0 comments on commit 8b3dcde

Please sign in to comment.