Conditions | 4 |
Total Lines | 24 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 4 |
Changes | 0 |
1 | package content |
||
15 | func (generator *htmlGenerator) GenerateContent(ctx context.Context, response *openapi3.Response, contentType string) (interface{}, error) { |
||
16 | 1 | originMediaType := response.Content.Get(contentType) |
|
17 | |||
18 | 1 | schema := originMediaType.Schema |
|
19 | |||
20 | 1 | if schema == nil || schema.Value.Type != "string" || schema.Value.Format != "html" { |
|
21 | 1 | logger := logcontext.LoggerFromContext(ctx) |
|
22 | 1 | logger.Warnf("only string schema with html format is supported for '%s' content type", contentType) |
|
23 | |||
24 | 1 | schema = &openapi3.SchemaRef{ |
|
25 | Value: &openapi3.Schema{ |
||
26 | Type: "string", |
||
27 | Format: "html", |
||
28 | }, |
||
29 | } |
||
30 | } |
||
31 | |||
32 | 1 | mediaType := &openapi3.MediaType{ |
|
33 | Schema: schema, |
||
34 | Example: originMediaType.Example, |
||
35 | Examples: originMediaType.Examples, |
||
36 | } |
||
37 | |||
38 | 1 | return generator.contentGenerator.GenerateData(ctx, mediaType) |
|
39 | } |
||
40 |