Skip to content

Commit

Permalink
optimize
Browse files Browse the repository at this point in the history
code optimization
  • Loading branch information
sdghchj committed Mar 23, 2020
1 parent 4922334 commit a4c0f6d
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions operation.go
Expand Up @@ -647,7 +647,7 @@ func (nested *nestedField) getSchema() *spec.Schema {
return &spec.Schema{SchemaProps: spec.SchemaProps{Ref: nested.Ref}}
}

func (nested *nestedField) fillNestedSchema(response spec.Response, ref spec.Ref) {
func (nested *nestedField) fillNestedSchema(response *spec.Response, ref spec.Ref) {
props := make(map[string]spec.Schema, 0)
if nested.IsArray {
props[nested.Name] = spec.Schema{SchemaProps: spec.SchemaProps{
Expand All @@ -663,9 +663,7 @@ func (nested *nestedField) fillNestedSchema(response spec.Response, ref spec.Ref
Properties: props,
},
}
response.Schema.AllOf = make([]spec.Schema, 0)
response.Schema.AllOf = append(response.Schema.AllOf, spec.Schema{SchemaProps: spec.SchemaProps{Ref: ref}})
response.Schema.AllOf = append(response.Schema.AllOf, nestedSpec)
response.Schema.AllOf = []spec.Schema{spec.Schema{SchemaProps: spec.SchemaProps{Ref: ref}},nestedSpec}
}

var nestedObjectPattern = regexp.MustCompile(`^([\w\-\.\/]+)\{(.*)=([^\[\]]*)\}$`)
Expand Down Expand Up @@ -748,7 +746,7 @@ func (operation *Operation) ParseResponseComment(commentLine string, astFile *as
if nested == nil {
response.Schema.Ref = ref
} else {
nested.fillNestedSchema(response, ref)
nested.fillNestedSchema(&response, ref)
}

} else if schemaType == "array" {
Expand Down

0 comments on commit a4c0f6d

Please sign in to comment.