Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with Stability API: Objects in multi-part form content in API spec generates invalid code #55

Open
varon opened this issue Mar 29, 2024 · 3 comments

Comments

@varon
Copy link
Contributor

varon commented Mar 29, 2024

An example of this is in the stability API, which produces invalid code (compile errors).

config file:

{
  "schema": "./openapi-stability.json",
  "project": "Stability",
  "output": "../../gen/Stability",
  "target": "fsharp",
  "synchronous": true,
}

Errors:

0>------- Started building project: Stability
0>Client.fs(1104,15): Error FS0041 : No overloads match for method 'multipartFormData'.
Known types of arguments: string * TextPrompts

Available overloads:
 - static member RequestPart.multipartFormData: key: string * value: System.DateTimeOffset -> RequestPart // Argument 'value' doesn't match
 - static member RequestPart.multipartFormData: key: string * value: System.Guid -> RequestPart // Argument 'value' doesn't match
 - static member RequestPart.multipartFormData: key: string * value: bool -> RequestPart // Argument 'value' doesn't match
 - static member RequestPart.multipartFormData: key: string * value: byte array -> RequestPart // Argument 'value' doesn't match
 - static member RequestPart.multipartFormData: key: string * value: double -> RequestPart // Argument 'value' doesn't match
 - static member RequestPart.multipartFormData: key: string * value: float32 -> RequestPart // Argument 'value' doesn't match
 - static member RequestPart.multipartFormData: key: string * value: int -> RequestPart // Argument 'value' doesn't match
 - static member RequestPart.multipartFormData: key: string * value: int64 -> RequestPart // Argument 'value' doesn't match
 - static member RequestPart.multipartFormData: key: string * value: string -> RequestPart // Argument 'value' doesn't match
 - static member RequestPart.multipartFormData: key: string * values: System.Guid list -> RequestPart // Argument 'values' doesn't match
 - static member RequestPart.multipartFormData: key: string * values: int list -> RequestPart // Argument 'values' doesn't match
 - static member RequestPart.multipartFormData: key: string * values: int64 list -> RequestPart // Argument 'values' doesn't match
 - static member RequestPart.multipartFormData: key: string * values: string list -> RequestPart // Argument 'values' doesn't match

I'm not sure how we go about solving this - issue seems to be with their API defining objects in multi-part forms.

You can view an example in their API docs here:
https://platform.stability.ai/docs/api-reference#tag/Image-to-Image/operation/imageToImage - see the text_prompts parameter.

I can give this a bash if you can outline the steps to solve it.

@Zaid-Ajaj
Copy link
Owner

Hmm that's a difficult one because here we probably need to flatten the structure we get into a list of RequestParts 🤔 the code generator needs to understand that this parameter is a complex structure, then generate code that flattens it when building the parts of the request body. Sorry if this is a bit vague, some of these API are really weird to work with.

@Zaid-Ajaj
Copy link
Owner

Zaid-Ajaj commented Mar 29, 2024

Example of how the generated code should look like:

for (part, i) in flatten textPrompts do
  yield RequestPart.multipartFormData($"text_prompts[{i}].text", part.text)
  yield RequestPart.multipartFormData($"text_prompts[{i}].weight", part.weight)

@varon
Copy link
Contributor Author

varon commented Mar 30, 2024

(The fix for #56 is unrelated to this - FYI)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants