danielgtaylor / danielgtaylor/huma

Array Representation in Generated Documentation

Open
#636 1 comment 2 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
4.4k
Forks
285
Avg merge
40m
Merged PRs (30d)
1

Description

I'm having some issues with generated documentation when it comes to array representation. Here is my struct code:
```
type ThingsPage struct {
Things []Thing `json:"things" doc:"A list of things."`
}
```

The generated yaml looks like
```
ThingsPage:
additionalProperties: true
properties:
things:
description: A list of things.
items:
$ref: "#/components/schemas/Thing"
type:
- array
- "null"
required:
- things
type: object
```

The `"null"` under the type removes the ability for the visualized documentation to expand the properties of `Thing`. I tried a couple things, like adding nullable:"false" and required:"true" struct tags, but nothing seems to remove that `"null"` from the generated yaml. The desired yaml should look like
```
ThingsPage:
additionalProperties: true
properties:
things:
description: A list of things.
items:
$ref: "#/components/schemas/Thing"
type: array
required:
- things
type: object
```

Any help would be appreciated.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.