I'm currently using very outdated library v1.1.1-0.20190620131940-98aa997b1687, and I want to upgrade to latest, but I was really surprised when the swagger validate shows much more warnings with new version.
Here is an example of two structs:
type Parent struct {
FieldA string
}
type Child struct {
Parent
FieldB int
}
with v1.1.1 it generates just one definition:
{
"definitions": {
"restfulspec.Child": {
"required": [
"FieldA",
"FieldB"
],
"properties": {
"FieldA": {
"type": "string"
},
"FieldB": {
"type": "integer",
"format": "int32"
}
}
}
}
}
but v2.6.1 generates two definitions:
{
"definitions": {
"restfulspec.Child": {
"required": [
"FieldA",
"FieldB"
],
"properties": {
"FieldA": {
"type": "string"
},
"FieldB": {
"type": "integer",
"format": "int32"
}
}
},
"restfulspec.Parent": {
"required": [
"FieldA"
],
"properties": {
"FieldA": {
"type": "string"
}
}
}
}
}
and the swagger validate shows a warning:
WARNING: definition "#/definitions/restfulspec.Parents" is not used anywhere
It would be great if you can exclude fix the issue.
Here is the test case:
type Parent struct {
FieldA string
}
type Child struct {
Parent
FieldB int
}
func TestParentChildArray(t *testing.T) {
db := definitionBuilder{Definitions: spec.Definitions{}, Config: Config{}}
db.addModelFrom(Child{})
s := spec.Schema{
SchemaProps: spec.SchemaProps{
Definitions: db.Definitions,
},
}
_, ok := db.Definitions["restfulspec.Parent"]
if ok {
data, _ := json.MarshalIndent(s, "", " ")
t.Log(string(data))
t.Fail()
}
}
I'm currently using very outdated library
v1.1.1-0.20190620131940-98aa997b1687, and I want to upgrade to latest, but I was really surprised when theswagger validateshows much more warnings with new version.Here is an example of two structs:
with
v1.1.1it generates just one definition:{ "definitions": { "restfulspec.Child": { "required": [ "FieldA", "FieldB" ], "properties": { "FieldA": { "type": "string" }, "FieldB": { "type": "integer", "format": "int32" } } } } }but
v2.6.1generates two definitions:{ "definitions": { "restfulspec.Child": { "required": [ "FieldA", "FieldB" ], "properties": { "FieldA": { "type": "string" }, "FieldB": { "type": "integer", "format": "int32" } } }, "restfulspec.Parent": { "required": [ "FieldA" ], "properties": { "FieldA": { "type": "string" } } } } }and the
swagger validateshows a warning:It would be great if you can exclude fix the issue.
Here is the test case: