Skip to content

Commit

Permalink
fix when a $ref is used in additionalProperties
Browse files Browse the repository at this point in the history
  • Loading branch information
sachaarbonel committed Sep 18, 2023
1 parent 0bd06ea commit 32317dc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions openapi-gen/openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,5 +389,12 @@ func getReferencesFromTypes(schema *openapi3.Schema) []string {
}
}

if schema.AdditionalProperties.Schema != nil {
if schema.AdditionalProperties.Schema.Ref != "" {
refs = append(refs, schema.AdditionalProperties.Schema.Ref)
} else if schema.AdditionalProperties.Schema.Value != nil {
refs = append(refs, getReferencesFromTypes(schema.AdditionalProperties.Schema.Value)...)
}
}
return refs
}
3 changes: 3 additions & 0 deletions openapi-gen/templates/python/type.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
{{- if and (.Value.AdditionalProperties.Schema) (not (contains $typingImports "Dict"))}}
{{- $typingImports = append $typingImports "Dict"}}
{{- end}}
{{- if and (.Value.AdditionalProperties.Schema) (.Value.AdditionalProperties.Schema.Ref) }}
{{- $_ := $imports.Add .Value.AdditionalProperties.Schema.Ref }}
{{- end}}
{{- end}}
{{- end}}

Expand Down

0 comments on commit 32317dc

Please sign in to comment.