Conditions | 7 |
Total Lines | 17 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 7 |
Changes | 0 |
1 | package data |
||
14 | func (generator *coordinatingMediaGenerator) GenerateData(ctx context.Context, mediaType *openapi3.MediaType) (Data, error) { |
||
15 | 1 | if generator.useExamples == IfPresent || generator.useExamples == Exclusively { |
|
16 | 1 | if mediaType.Example != nil { |
|
17 | 1 | return mediaType.Example, nil |
|
18 | } |
||
19 | 1 | if mediaType.Examples != nil { |
|
20 | 1 | for _, example := range mediaType.Examples { |
|
21 | 1 | return example.Value.Value, nil |
|
22 | } |
||
23 | } |
||
24 | } |
||
25 | |||
26 | 1 | if generator.useExamples == Exclusively { |
|
27 | 1 | return nil, nil |
|
28 | } |
||
29 | |||
30 | 1 | return generator.schemaGenerator.GenerateDataBySchema(ctx, mediaType.Schema.Value) |
|
31 | } |
||
32 |