Skip to content

Commit

Permalink
Stricter check for generating synthetic fixtures (#450)
Browse files Browse the repository at this point in the history
  • Loading branch information
anniel-stripe authored Aug 28, 2023
1 parent cfee1af commit ee98add
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion server/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,10 @@ func (g *DataGenerator) generateInternal(params *GenerateParams) (interface{}, e
}

// Generate a synthethic schema as a last ditch effort
if (example == nil || example.value == nil) && schema.XResourceID == "" {
// Note that if example.value is nil, we only want to generate
// a synthetic fixture if the user has requested expansions.
// Otherwise, we'll cause bugs like https://github.com/stripe/stripe-mock/issues/447
if example == nil || (params.Expansions != nil && example.value == nil) && schema.XResourceID == "" {
example = &valueWrapper{value: generateSyntheticFixture(schema, context, params.Expansions)}

context = fmt.Sprintf("%sGenerated synthetic fixture: %+v\n", context, schema)
Expand Down

0 comments on commit ee98add

Please sign in to comment.