File tree Expand file tree Collapse file tree 4 files changed +55
-8
lines changed Expand file tree Collapse file tree 4 files changed +55
-8
lines changed Original file line number Diff line number Diff line change @@ -90,16 +90,17 @@ type Shape struct {
9090	OriginalShapeName  string  `json:"-"` 
9191
9292	// Map of exported member names to the ShapeReference. 
93- 	MemberRefs        map [string ]* ShapeRef  `json:"members"` 
94- 	MemberRef         ShapeRef              `json:"member"`  // List ref 
95- 	KeyRef            ShapeRef              `json:"key"`     // map key ref 
96- 	ValueRef          ShapeRef              `json:"value"`   // map value ref 
97- 	Required          []string 
98- 	Payload           string 
99- 	Type              string 
93+ 	MemberRefs  map [string ]* ShapeRef  `json:"members"` 
94+ 	MemberRef   ShapeRef              `json:"member"`  // List ref 
95+ 	KeyRef      ShapeRef              `json:"key"`     // map key ref 
96+ 	ValueRef    ShapeRef              `json:"value"`   // map value ref 
97+ 	Pattern     string                `json:"pattern"` 
98+ 	Required    []string 
99+ 	Payload     string 
100+ 	Type        string 
100101	// this is being added for type union specifically. We want to generate 
101102	//  api as struct and handle setSDK and setResource differently 
102- 	RealType          string 		 
103+ 	RealType          string 
103104	Exception         bool 
104105	Enum              []string 
105106	EnumConsts        []string 
Original file line number Diff line number Diff line change @@ -231,6 +231,12 @@ func createApiShape(shape Shape) (*awssdkmodel.Shape, error) {
231231	if  ok  {
232232		apiShape .DefaultValue  =  fmt .Sprintf ("%v" , val )
233233	}
234+ 
235+ 	pattern , ok  :=  shape .Traits ["smithy.api#pattern" ]
236+ 	if  ok  {
237+ 		apiShape .Pattern  =  pattern .(string )
238+ 	}
239+ 
234240	documentation , _  :=  shape .Traits ["smithy.api#documentation" ].(string )
235241	apiShape .Documentation  =  awssdkmodel .AppendDocstring ("" , documentation )
236242
Original file line number Diff line number Diff line change @@ -104,6 +104,15 @@ func (f *Field) GetDocumentation() string {
104104			out .WriteString (f .ShapeRef .Documentation )
105105		}
106106	}
107+ 
108+ 	if  f .ShapeRef  !=  nil  &&  f .ShapeRef .Shape  !=  nil  &&  f .ShapeRef .Shape .Pattern  !=  ""  {
109+ 		if  hasShapeDoc  {
110+ 			out .WriteString ("\n //\n " )
111+ 		}
112+ 		out .WriteString ("// " )
113+ 		out .WriteString (fmt .Sprintf ("Regex Pattern: `%s`" , f .ShapeRef .Shape .Pattern ))
114+ 	}
115+ 
107116	if  cfg  ==  nil  {
108117		return  out .String ()
109118	}
Original file line number Diff line number Diff line change @@ -338,3 +338,34 @@ func TestFieldPathWithUnderscore(t *testing.T) {
338338	field .Path  =  "subPathA.subPathB.MyField" 
339339	assert .Equal ("subPathA_subPathB_MyField" , field .FieldPathWithUnderscore ())
340340}
341+ 
342+ func  TestFieldWithPattern (t  * testing.T ) {
343+ 	require  :=  require .New (t )
344+ 
345+ 	g  :=  testutil .NewModelForServiceWithOptions (t , "eks" ,
346+ 		& testutil.TestingModelOptions {
347+ 			GeneratorConfigFile :     "generator.yaml" ,
348+ 			DocumentationConfigFile : "documentation.yaml" ,
349+ 		},
350+ 	)
351+ 
352+ 	crds , err  :=  g .GetCRDs ()
353+ 	require .Nil (err )
354+ 
355+ 	crd  :=  getCRDByName ("AddOn" , crds )
356+ 	require .NotNil (crd )
357+ 
358+ 	specFields  :=  crd .SpecFields 
359+ 
360+ 	// We have not altered the docstring for Version from the 
361+ 	// docstring that comes in the doc-2.json file... 
362+ 	ltdField  :=  specFields ["ClusterName" ]
363+ 	require .NotNil (ltdField )
364+ 	require .NotNil (ltdField .ShapeRef )
365+ 	require .NotEmpty (ltdField .ShapeRef .Shape .Pattern )
366+ 
367+ 	require .Equal (
368+ 		"// The name of your cluster.\n //\n // Regex Pattern: `^[0-9A-Za-z][A-Za-z0-9\\ -_]*$`" ,
369+ 		ltdField .GetDocumentation (),
370+ 	)
371+ }
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments