@@ -311,7 +311,9 @@ func (g *GeneratorEnvironment) Accept(visitor GeneratorEnvironmentVisitor) error
311311}
312312
313313type GeneratorOutputConfig struct {
314- Path string `json:"path"`
314+ Path string `json:"path"`
315+ // A static file that defines the list of features supported by the generator.
316+ FeaturesFilepath * string `json:"featuresFilepath,omitempty"`
315317 SnippetFilepath * string `json:"snippetFilepath,omitempty"`
316318 SnippetTemplateFilepath * string `json:"snippetTemplateFilepath,omitempty"`
317319 PublishingMetadata * PublishingMetadata `json:"publishingMetadata,omitempty"`
@@ -1635,6 +1637,63 @@ func (e *EndpointSnippet) Accept(visitor EndpointSnippetVisitor) error {
16351637 }
16361638}
16371639
1640+ // Unique identifiers for the different features that can be demonstrated in the snippets.
1641+ type FeatureType uint
1642+
1643+ const (
1644+ FeatureTypeUsage FeatureType = iota + 1
1645+ FeatureTypeTimeouts
1646+ FeatureTypeRequestOptions
1647+ FeatureTypeRetries
1648+ FeatureTypeErrors
1649+ )
1650+
1651+ func (f FeatureType ) String () string {
1652+ switch f {
1653+ default :
1654+ return strconv .Itoa (int (f ))
1655+ case FeatureTypeUsage :
1656+ return "USAGE"
1657+ case FeatureTypeTimeouts :
1658+ return "TIMEOUTS"
1659+ case FeatureTypeRequestOptions :
1660+ return "REQUEST_OPTIONS"
1661+ case FeatureTypeRetries :
1662+ return "RETRIES"
1663+ case FeatureTypeErrors :
1664+ return "ERRORS"
1665+ }
1666+ }
1667+
1668+ func (f FeatureType ) MarshalJSON () ([]byte , error ) {
1669+ return []byte (fmt .Sprintf ("%q" , f .String ())), nil
1670+ }
1671+
1672+ func (f * FeatureType ) UnmarshalJSON (data []byte ) error {
1673+ var raw string
1674+ if err := json .Unmarshal (data , & raw ); err != nil {
1675+ return err
1676+ }
1677+ switch raw {
1678+ case "USAGE" :
1679+ value := FeatureTypeUsage
1680+ * f = value
1681+ case "TIMEOUTS" :
1682+ value := FeatureTypeTimeouts
1683+ * f = value
1684+ case "REQUEST_OPTIONS" :
1685+ value := FeatureTypeRequestOptions
1686+ * f = value
1687+ case "RETRIES" :
1688+ value := FeatureTypeRetries
1689+ * f = value
1690+ case "ERRORS" :
1691+ value := FeatureTypeErrors
1692+ * f = value
1693+ }
1694+ return nil
1695+ }
1696+
16381697type GoEndpointSnippet struct {
16391698 // A full endpoint snippet, including the client instantiation, e.g.
16401699 //
@@ -1740,8 +1799,11 @@ type Snippets struct {
17401799 Endpoints []* Endpoint `json:"endpoints,omitempty"`
17411800 // A collection of endpoint snippets that demonstrate a particular feature.
17421801 //
1743- // For simplicity, this is just a simple map for now.
1802+ // The key is a free-form string to allow for features not yet defined in the schema,
1803+ // but users are expected to use the FeatureType enum string representations.
17441804 Features map [string ][]* Endpoint `json:"features,omitempty"`
1805+ // A list of requirements to use the generated snippets.
1806+ Requirements []string `json:"requirements,omitempty"`
17451807}
17461808
17471809type TypeId = string
0 commit comments