Skip to content

Commit 36a7778

Browse files
Release v0.5.0
1 parent f51b14a commit 36a7778

File tree

2 files changed

+197
-2
lines changed

2 files changed

+197
-2
lines changed

core/request_option.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func (r *RequestOptions) cloneHeader() http.Header {
4444
headers := r.HTTPHeader.Clone()
4545
headers.Set("X-Fern-Language", "Go")
4646
headers.Set("X-Fern-SDK-Name", "github.com/fern-api/generator-cli-go")
47-
headers.Set("X-Fern-SDK-Version", "v0.4.6")
47+
headers.Set("X-Fern-SDK-Version", "v0.5.0")
4848
return headers
4949
}
5050

types.go

Lines changed: 196 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,74 @@ func (c *CargoPublishInfo) String() string {
285285
return fmt.Sprintf("%#v", c)
286286
}
287287

288+
// A code snippet that will be wrapped in a code fence with the specified language.
289+
// If no language is specified, the generator's language will be used.
290+
type CodeSnippet struct {
291+
// Discriminator field to identify this as a code snippet.
292+
Content string `json:"content" url:"content"`
293+
// The language for the code fence. If not specified, the generator's language will be used.
294+
Language *string `json:"language,omitempty" url:"language,omitempty"`
295+
type_ string
296+
297+
extraProperties map[string]interface{}
298+
_rawJSON json.RawMessage
299+
}
300+
301+
func (c *CodeSnippet) GetExtraProperties() map[string]interface{} {
302+
return c.extraProperties
303+
}
304+
305+
func (c *CodeSnippet) Type() string {
306+
return c.type_
307+
}
308+
309+
func (c *CodeSnippet) UnmarshalJSON(data []byte) error {
310+
type embed CodeSnippet
311+
var unmarshaler = struct {
312+
embed
313+
}{
314+
embed: embed(*c),
315+
}
316+
if err := json.Unmarshal(data, &unmarshaler); err != nil {
317+
return err
318+
}
319+
*c = CodeSnippet(unmarshaler.embed)
320+
c.type_ = "code"
321+
322+
extraProperties, err := core.ExtractExtraProperties(data, *c, "type")
323+
if err != nil {
324+
return err
325+
}
326+
c.extraProperties = extraProperties
327+
328+
c._rawJSON = json.RawMessage(data)
329+
return nil
330+
}
331+
332+
func (c *CodeSnippet) MarshalJSON() ([]byte, error) {
333+
type embed CodeSnippet
334+
var marshaler = struct {
335+
embed
336+
Type string `json:"type"`
337+
}{
338+
embed: embed(*c),
339+
Type: "code",
340+
}
341+
return json.Marshal(marshaler)
342+
}
343+
344+
func (c *CodeSnippet) String() string {
345+
if len(c._rawJSON) > 0 {
346+
if value, err := core.StringifyJSON(c._rawJSON); err == nil {
347+
return value
348+
}
349+
}
350+
if value, err := core.StringifyJSON(c); err == nil {
351+
return value
352+
}
353+
return fmt.Sprintf("%#v", c)
354+
}
355+
288356
type ComposerPublishInfo struct {
289357
PackageName string `json:"packageName" url:"packageName"`
290358

@@ -438,6 +506,8 @@ type GithubRemote struct {
438506
RepoUrl string `json:"repoUrl" url:"repoUrl"`
439507
// The token used to clone the GitHub repository.
440508
InstallationToken string `json:"installationToken" url:"installationToken"`
509+
// The branch to clone from. If not specified, the default branch will be used.
510+
Branch *string `json:"branch,omitempty" url:"branch,omitempty"`
441511

442512
extraProperties map[string]interface{}
443513
_rawJSON json.RawMessage
@@ -759,6 +829,71 @@ func (l *LanguageInfo) Accept(visitor LanguageInfoVisitor) error {
759829
return fmt.Errorf("type %T does not define a non-empty union type", l)
760830
}
761831

832+
// A markdown snippet that will be rendered as-is without code fences.
833+
type MarkdownSnippet struct {
834+
// Discriminator field to identify this as a markdown snippet.
835+
Content string `json:"content" url:"content"`
836+
type_ string
837+
838+
extraProperties map[string]interface{}
839+
_rawJSON json.RawMessage
840+
}
841+
842+
func (m *MarkdownSnippet) GetExtraProperties() map[string]interface{} {
843+
return m.extraProperties
844+
}
845+
846+
func (m *MarkdownSnippet) Type() string {
847+
return m.type_
848+
}
849+
850+
func (m *MarkdownSnippet) UnmarshalJSON(data []byte) error {
851+
type embed MarkdownSnippet
852+
var unmarshaler = struct {
853+
embed
854+
}{
855+
embed: embed(*m),
856+
}
857+
if err := json.Unmarshal(data, &unmarshaler); err != nil {
858+
return err
859+
}
860+
*m = MarkdownSnippet(unmarshaler.embed)
861+
m.type_ = "markdown"
862+
863+
extraProperties, err := core.ExtractExtraProperties(data, *m, "type")
864+
if err != nil {
865+
return err
866+
}
867+
m.extraProperties = extraProperties
868+
869+
m._rawJSON = json.RawMessage(data)
870+
return nil
871+
}
872+
873+
func (m *MarkdownSnippet) MarshalJSON() ([]byte, error) {
874+
type embed MarkdownSnippet
875+
var marshaler = struct {
876+
embed
877+
Type string `json:"type"`
878+
}{
879+
embed: embed(*m),
880+
Type: "markdown",
881+
}
882+
return json.Marshal(marshaler)
883+
}
884+
885+
func (m *MarkdownSnippet) String() string {
886+
if len(m._rawJSON) > 0 {
887+
if value, err := core.StringifyJSON(m._rawJSON); err == nil {
888+
return value
889+
}
890+
}
891+
if value, err := core.StringifyJSON(m); err == nil {
892+
return value
893+
}
894+
return fmt.Sprintf("%#v", m)
895+
}
896+
762897
type MavenPublishInfo struct {
763898
Artifact string `json:"artifact" url:"artifact"`
764899
Group string `json:"group" url:"group"`
@@ -1075,7 +1210,7 @@ type ReadmeFeature struct {
10751210
Description *string `json:"description,omitempty" url:"description,omitempty"`
10761211
Addendum *string `json:"addendum,omitempty" url:"addendum,omitempty"`
10771212
Advanced *bool `json:"advanced,omitempty" url:"advanced,omitempty"`
1078-
Snippets []string `json:"snippets,omitempty" url:"snippets,omitempty"`
1213+
Snippets []*Snippet `json:"snippets,omitempty" url:"snippets,omitempty"`
10791214
// If true, the feature block should be rendered even if we don't receive a snippet for it.
10801215
// This is useful for features that are always supported, but might not require a snippet
10811216
// to explain.
@@ -1285,6 +1420,66 @@ func (r *RustInfo) String() string {
12851420
return fmt.Sprintf("%#v", r)
12861421
}
12871422

1423+
// A snippet that can be either a plain string (treated as code in the generator's language),
1424+
// markdown content, or a code block with optional language override.
1425+
// Plain strings are supported for backwards compatibility.
1426+
type Snippet struct {
1427+
String string
1428+
MarkdownSnippet *MarkdownSnippet
1429+
CodeSnippet *CodeSnippet
1430+
}
1431+
1432+
func (s *Snippet) UnmarshalJSON(data []byte) error {
1433+
var valueString string
1434+
if err := json.Unmarshal(data, &valueString); err == nil {
1435+
s.String = valueString
1436+
return nil
1437+
}
1438+
valueMarkdownSnippet := new(MarkdownSnippet)
1439+
if err := json.Unmarshal(data, &valueMarkdownSnippet); err == nil {
1440+
s.MarkdownSnippet = valueMarkdownSnippet
1441+
return nil
1442+
}
1443+
valueCodeSnippet := new(CodeSnippet)
1444+
if err := json.Unmarshal(data, &valueCodeSnippet); err == nil {
1445+
s.CodeSnippet = valueCodeSnippet
1446+
return nil
1447+
}
1448+
return fmt.Errorf("%s cannot be deserialized as a %T", data, s)
1449+
}
1450+
1451+
func (s Snippet) MarshalJSON() ([]byte, error) {
1452+
if s.String != "" {
1453+
return json.Marshal(s.String)
1454+
}
1455+
if s.MarkdownSnippet != nil {
1456+
return json.Marshal(s.MarkdownSnippet)
1457+
}
1458+
if s.CodeSnippet != nil {
1459+
return json.Marshal(s.CodeSnippet)
1460+
}
1461+
return nil, fmt.Errorf("type %T does not include a non-empty union type", s)
1462+
}
1463+
1464+
type SnippetVisitor interface {
1465+
VisitString(string) error
1466+
VisitMarkdownSnippet(*MarkdownSnippet) error
1467+
VisitCodeSnippet(*CodeSnippet) error
1468+
}
1469+
1470+
func (s *Snippet) Accept(visitor SnippetVisitor) error {
1471+
if s.String != "" {
1472+
return visitor.VisitString(s.String)
1473+
}
1474+
if s.MarkdownSnippet != nil {
1475+
return visitor.VisitMarkdownSnippet(s.MarkdownSnippet)
1476+
}
1477+
if s.CodeSnippet != nil {
1478+
return visitor.VisitCodeSnippet(s.CodeSnippet)
1479+
}
1480+
return fmt.Errorf("type %T does not include a non-empty union type", s)
1481+
}
1482+
12881483
type SwiftInfo struct {
12891484
PublishInfo *SwiftPackageManagerPublishInfo `json:"publishInfo,omitempty" url:"publishInfo,omitempty"`
12901485

0 commit comments

Comments
 (0)