Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ernado/optexample
https://github.com/ernado/optexample
Last synced: about 20 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/ernado/optexample
- Owner: ernado
- License: apache-2.0
- Created: 2024-03-09T12:46:34.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-03-09T12:50:15.000Z (8 months ago)
- Last Synced: 2024-10-15T02:47:37.418Z (24 days ago)
- Language: Go
- Size: 20.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# optexample
We have following shema:
```yaml
Example:
type: object
required:
- Required
- NullableRequired
properties:
Optional:
type: string
NullableOptional:
type: string
nullable: true
Required:
type: string
example: "example"
NullableRequired:
type: string
nullable: true
```## ogen
```go
type Example struct {
Optional OptString `json:"Optional"`
NullableOptional OptNilString `json:"NullableOptional"`
Required string `json:"Required"`
NullableRequired NilString `json:"NullableRequired"`
}type OptString struct {
Value string
Set bool
}type OptNilString struct {
Value string
Set bool
Null bool
}type NilString struct {
Value string
Null bool
}
```## oapi-codegen
```go
type Example struct {
NullableOptional nullable.Nullable[string] `json:"NullableOptional,omitempty"`
NullableRequired nullable.Nullable[string] `json:"NullableRequired"`
Optional *string `json:"Optional,omitempty"`
Required string `json:"Required"`
}// from nullable package
type Nullable[T any] map[bool]T
```