google / google/gnostic-models
Strings.ToRawInfo generate empty node
- Dominant language
- Go
- Stars
- 20
- Forks
- 11
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
## Issue
The `ToRawInfo` method on `openapiv3.Strings` return an empty node without writing actual content.
```yaml
type: array
items:
discriminator:
propertyName: type
mapping: {} # <------ Empty node
anyOf:
- $ref: '...'
```
---
## Current implementation:
https://github.com/google/gnostic-models/blob/289d7b4936d1c53094daaadca34f8fcf7a916454/openapiv3/OpenAPIv3.go#L8557-L8565
---
# Fix:
```go
// ToRawInfo returns a description of Strings suitable for JSON or YAML export.
func (m *Strings) ToRawInfo() *yaml.Node {
info := compiler.NewMappingNode()
if m == nil {
return info
}
// &{Name:additionalProperties Type:NamedString StringEnumValues:[] MapType:string Repeated:true Pattern: Implicit:true Description:}
for _, p := range m.AdditionalProperties {
info.Content = append(info.Content, compiler.NewScalarNodeForString(p.Name))
info.Content = append(info.Content, compiler.NewScalarNodeForString(p.Value))
}
return info
}
```
Produces:
```yaml
discriminator:
propertyName: type
mapping:
name_example: 'value_example'
# ...
anyOf:
- $ref: '...'
```
---
Made [this PR](https://github.com/google/gnostic-models/pull/25) to fix it
Hope you see this soon !
Contributor guide
Assessment
This issue has not been assessed yet.