Skip to content

Commit

Permalink
sdk支持FormData
Browse files Browse the repository at this point in the history
  • Loading branch information
Val-istar-Guo committed Dec 18, 2024
1 parent 0be3302 commit 529d21f
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 31 deletions.
5 changes: 5 additions & 0 deletions .changeset/heavy-news-collect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@opendoc/sdk": patch
---

sdk 支持 FormData
92 changes: 61 additions & 31 deletions pkg/sdk/src/templates/openapi-core/operation.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -30,41 +30,71 @@ export function {{h__get-safe-operation-name pathname method operation}}<STATUS
{{/each~}}
{{/if}}

{{~#each operation.requestBody.content}}
{{~#if (r__and (r__equals @key "application/json") this.schema)}}
{{~#each operation.requestBody.content as |body contentType|}}

{{~#*inline "SchemaSend"}}
{{#each properties}}
{{~#if body.schema}}
{{~#if (r__equals contentType "application/json")}}

{{~#*inline "eachProperties"}}
{{~#if (h__is-ref this)}}
{{~#with (h__dereference this)}}
{{~> eachProperties this}}
{{~/with}}
{{~else if this.allOf}}
{{#each this.allOf}}
{{~> eachProperties this}}
{{/each}}
{{~else if this.oneOf}}
{{#each this.oneOf}}
{{~> eachProperties this}}
{{/each}}
{{~else if this.anyOf}}
{{#each this.anyOf}}
{{~> eachProperties this}}
{{/each}}
{{~else}}
{{#each this.properties}}
if (arg && "{{@key}}" in arg) req.send({ "{{@key}}": arg["{{@key}}"] })
{{/each}}
{{/inline}}


{{~#*inline "send"}}
{{~#if (h__is-ref this)}}
{{~#with (h__dereference this)}}
{{~> send this}}
{{~/with}}
{{~else if this.allOf}}
{{#each this.allOf}}
{{~> send this}}
{{/each}}
{{~else if this.oneOf}}
{{#each this.oneOf}}
{{~> send this}}
{{/each}}
{{~else if this.anyOf}}
{{#each this.anyOf}}
{{~> send this}}
{{/each}}
{{~else}}
{{~> SchemaSend this}}
{{~/if}}
{{/inline}}
{{/each}}
{{~/if}}
{{/inline}}

{{~> eachProperties body.schema}}

{{~> send this.schema}}
{{~else if (r__equals contentType "multipart/form-data")}}

{{~#*inline "eachProperties"}}
{{~#if (h__is-ref this)}}
{{~#with (h__dereference this)}}
{{~> eachProperties this}}
{{~/with}}
{{~else if this.allOf}}
{{#each this.allOf}}
{{~> eachProperties this}}
{{/each}}
{{~else if this.oneOf}}
{{#each this.oneOf}}
{{~> eachProperties this}}
{{/each}}
{{~else if this.anyOf}}
{{#each this.anyOf}}
{{~> eachProperties this}}
{{/each}}
{{~else}}
{{#each this.properties as |prop key|}}
{{~#if (r__equals prop.format "binary")}}
if (arg && "{{key}}" in arg) req.attach({ "{{key}}": arg["{{key}}"] })
{{~else}}
if (arg && "{{key}}" in arg) req.field({ "{{key}}": arg["{{key}}"] })
{{~/if}}
{{/each}}
{{~/if}}
{{/inline}}

{{~> eachProperties this.schema}}
{{~/if}}
{{~/if}}

{{~/if}}
{{~/each}}

return req as unknown as Keq<ResponseMap[STATUS], Operation<STATUS>>
Expand Down

0 comments on commit 529d21f

Please sign in to comment.