google / google/gnostic-models

Strings.ToRawInfo generate empty node

Open
#24 0 comments 0 reactions 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.