Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions openapi3gen/openapi3gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,10 @@ func (g *Generator) generateWithoutSaving(parents []*theTypeInfo, t reflect.Type

case reflect.Slice:
if t.Elem().Kind() == reflect.Uint8 {
if t == rawMessageType {
return &openapi3.SchemaRef{Value: schema}, nil
if t != rawMessageType {
schema.Type = &openapi3.Types{"string"}
schema.Format = "byte"
}
schema.Type = &openapi3.Types{"string"}
schema.Format = "byte"
} else {
schema.Type = &openapi3.Types{"array"}
items, err := g.generateSchemaRefFor(parents, t.Elem(), name, tag)
Expand Down
9 changes: 8 additions & 1 deletion openapi3gen/openapi3gen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,8 @@ func ExampleSchemaCustomizer() {
InnerFieldWithTag int `mymintag:"-1" mymaxtag:"50"`
NestedInnerBla
}
Enum2Field string `json:"enum2" myenumtag:"c,d"`
Enum2Field string `json:"enum2" myenumtag:"c,d"`
JsonField json.RawMessage `json:"rawmsg" myjsontag:"raw"`
}

type Bla struct {
Expand Down Expand Up @@ -435,6 +436,9 @@ func ExampleSchemaCustomizer() {
schema.Enum = append(schema.Enum, s)
}
}
if tag.Get("myjsontag") != "" {
schema.Description = "description"
}
return nil
})

Expand Down Expand Up @@ -487,6 +491,9 @@ func ExampleSchemaCustomizer() {
// "f"
// ],
// "type": "string"
// },
// "rawmsg": {
// "description": "description"
// }
// },
// "type": "object"
Expand Down
Loading