fern-api / fern

Input OpenAPI. Output SDKs and Docs.
https://buildwithfern.com
Apache License 2.0
2.69k stars 151 forks source link

feat(go): Add support for file upload dynamic snippets #5252

Open amckinney opened 6 hours ago

amckinney commented 6 hours ago

This updates Go's DynamicSnippetsGenerator so that it supports file upload snippets, and considers both the inlineFileProperties and inlinePathParameters configuration options.

For example, given the following request:

{
  endpoint: {
      method: "POST",
      path: "/just-file-with-query-params"
  },
  auth: undefined,
  pathParameters: undefined,
  queryParameters: {
      integer: 42,
      maybeString: "exists"
  },
  headers: undefined,
  requestBody: {
      file: "Hello, world!"
  }
}

The corresponding Go snippet with inlineFileProperties is shown below:

package example

import (
    context "context"
    acme "github.com/acme/acme-go"
    client "github.com/acme/acme-go/client"
    strings "strings"
)

func do() {
    client := client.NewClient()
    client.Service.JustFileWithQueryParams(
        context.TODO(),
        &acme.JustFileWithQueryParamsRequet{
            Integer: 42,
            MaybeString: acme.String(
                "exists",
            ),
            File: strings.NewReader(
                "Hello, world!",
            ),
        },
    )
}
github-actions[bot] commented 6 hours ago

🌿 Preview your docs: https://fern-preview-99ff8e8e-461e-4abd-b6ad-8f1edd22cb78.docs.buildwithfern.com/learn