Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nilablity Update w/ Rules #10

Merged
merged 3 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# openrtb [![Go Reference](https://pkg.go.dev/badge/github.com/prebid/openrtb/v19.svg)](https://pkg.go.dev/github.com/prebid/openrtb/v19) [![Test](https://github.com/prebid/openrtb/actions/workflows/test.yml/badge.svg)](https://github.com/prebid/openrtb/actions/workflows/test.yml)
# openrtb [![Go Reference](https://pkg.go.dev/badge/github.com/prebid/openrtb/v20.svg)](https://pkg.go.dev/github.com/prebid/openrtb/v20) [![Test](https://github.com/prebid/openrtb/actions/workflows/test.yml/badge.svg)](https://github.com/prebid/openrtb/actions/workflows/test.yml)

[OpenRTB](https://iabtechlab.com/standards/openrtb/), [AdCOM](https://iabtechlab.com/standards/openmedia) and [OpenRTB Dynamic Native Ads](https://iabtechlab.com/standards/openrtb-native/) types for [Go programming language](https://golang.org/)

Expand All @@ -9,24 +9,24 @@

**Requires Go 1.16+**

This library uses [Go modules](https://golang.org/ref/mod) ([tl;dr](https://blog.golang.org/using-go-modules)) and requires Go [1.16](https://golang.org/doc/go1.16)+ to enable the ability to issue release retractions.
This library uses [Go modules](https://golang.org/ref/mod) ([tl;dr](https://blog.golang.org/using-go-modules)) and requires Go [1.16](https://golang.org/doc/go1.16)+ for the ability to issue release retractions.

# Using

```bash
go get -u "github.com/prebid/openrtb/v19/..."
go get -u "github.com/prebid/openrtb/v20/..."
```

```go
import (
openrtb2 "github.com/prebid/openrtb/v19/openrtb2"
openrtb2 "github.com/prebid/openrtb/v20/openrtb2"

openrtb3 "github.com/prebid/openrtb/v19/openrtb3"
adcom1 "github.com/prebid/openrtb/v19/adcom1"
openrtb3 "github.com/prebid/openrtb/v20/openrtb3"
adcom1 "github.com/prebid/openrtb/v20/adcom1"

native1 "github.com/prebid/openrtb/v19/native1"
nreq "github.com/prebid/openrtb/v19/native1/request"
nres "github.com/prebid/openrtb/v19/native1/response"
native1 "github.com/prebid/openrtb/v20/native1"
nreq "github.com/prebid/openrtb/v20/native1/request"
nres "github.com/prebid/openrtb/v20/native1/response"
)
```

Expand All @@ -51,19 +51,19 @@ The `main` branch always contains latest code, so better use some package manage
- all enums, described in section 5, must be typed with section name singularized (e.g., "5.2 Banner Ad Types" -> `type BannerAdType int8`)
- all typed enums must have constants for each element, prefixed with type name (e.g., "5.2 Banner Ad Types - XHTML Text Ad (usually mobile)" -> `const BannerAdTypeXHTMLTextAd BannerAdType = 1`)
- never use `iota` for enum constants
- OpenRTB (2.x) section "5.1 Content Categories" should remain untyped and have no constants
- OpenRTB (2.x) "content categories" should remain untyped and have no constants

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section no longer exists but there are still several references to content categories.

## Pointers/omitempty
Pointer | Omitempty | When to use | Example
------- | --------- | -------------------------------------------------------------------- | ---------------------------------
no | no | _required_ in spec | `Audio.mimes`
yes | yes | _required_ in spec, but is a part of mutually-exclusive group | `Imp.{banner,video,audio,native}`
no | yes | zero value (`""`, `0`) is useless / has no meaning | `Device.ua`
yes | yes | zero value (`""`, `0`) or value absence (`null`) has special meaning | `Device.{dnt,lmt}`
no | no | _required_ in spec | `Audio.MIMEs`
yes | yes | _required_ in spec, but is a part of mutually-exclusive group | `Imp.{Banner,Video,Audio,Native}`
no | yes | zero value (`""`, `0`) has no meaning, is defined in the spec as the default value, or represents time / duration | `Device.UA`
yes | yes | zero value (`""`, `0`) or value absence (`null`) has special meaning | `Device.{DNT,Lmt}`

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added our new rules for this nilability update and fixed casing of examples to match the object model.

Using both pointer and `omitempty` is mostly just to save traffic / generate more "canonical" (strict) JSON.

## Documentation ([pkg.go.dev](https://pkg.go.dev/github.com/prebid/openrtb/v19))
## Documentation ([pkg.go.dev](https://pkg.go.dev/github.com/prebid/openrtb/v20))
- [Godoc: documenting Go code](http://blog.golang.org/godoc-documenting-go-code)
- Each entity (type, struct key or constant) should be documented
- Ideally, copy-paste descriptions as-is, but feel free to omit section numbers, so just `<GoTypeName> defines <copy-pasted description from spec>`
Expand Down
2 changes: 1 addition & 1 deletion adcom1/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# adcom1 [![GoDoc](https://godoc.org/github.com/prebid/openrtb/adcom1?status.svg)](https://pkg.go.dev/github.com/prebid/openrtb/v19/adcom1)
# adcom1 [![GoDoc](https://godoc.org/github.com/prebid/openrtb/adcom1?status.svg)](https://pkg.go.dev/github.com/prebid/openrtb/v20/adcom1)

[AdCOM](https://iabtechlab.com/standards/openmedia/) [1.0](https://github.com/InteractiveAdvertisingBureau/AdCOM) types for [Go programming language](https://golang.org/)
2 changes: 1 addition & 1 deletion adcom1/adcom1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
. "github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega"

. "github.com/prebid/openrtb/v19/adcom1"
. "github.com/prebid/openrtb/v20/adcom1"
)

var _ = DescribeTable(
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/prebid/openrtb/v19
module github.com/prebid/openrtb/v20

go 1.16

Expand Down
2 changes: 1 addition & 1 deletion native1/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# native1 [![GoDoc](https://godoc.org/github.com/prebid/openrtb/native1?status.svg)](https://pkg.go.dev/github.com/prebid/openrtb/v19/native1)
# native1 [![GoDoc](https://godoc.org/github.com/prebid/openrtb/native1?status.svg)](https://pkg.go.dev/github.com/prebid/openrtb/v20/native1)

[OpenRTB Dynamic Native Ads API](https://iabtechlab.com/standards/openrtb-native/) [1.2](https://iabtechlab.com/wp-content/uploads/2016/07/OpenRTB-Native-Ads-Specification-Final-1.2.pdf) section "7 Reference Lists/Enumerations" types for [Go programming language](https://golang.org/)

Expand Down
2 changes: 1 addition & 1 deletion native1/request/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# native1/request [![GoDoc](https://godoc.org/github.com/prebid/openrtb/native1/request?status.svg)](https://pkg.go.dev/github.com/prebid/openrtb/v19/native1/request)
# native1/request [![GoDoc](https://godoc.org/github.com/prebid/openrtb/native1/request?status.svg)](https://pkg.go.dev/github.com/prebid/openrtb/v20/native1/request)

[OpenRTB Dynamic Native Ads API](https://iabtechlab.com/standards/openrtb-native/) [1.2](https://iabtechlab.com/wp-content/uploads/2016/07/OpenRTB-Native-Ads-Specification-Final-1.2.pdf) section "4 Native Ad Request Markup Details" types for [Go programming language](https://golang.org/)
2 changes: 1 addition & 1 deletion native1/request/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package request
import (
"encoding/json"

"github.com/prebid/openrtb/v19/native1"
"github.com/prebid/openrtb/v20/native1"
)

// 4.6 Data Object
Expand Down
2 changes: 1 addition & 1 deletion native1/request/event_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package request
import (
"encoding/json"

"github.com/prebid/openrtb/v19/native1"
"github.com/prebid/openrtb/v20/native1"
)

// 4.7 Event Trackers Request Object
Expand Down
2 changes: 1 addition & 1 deletion native1/request/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package request
import (
"encoding/json"

"github.com/prebid/openrtb/v19/native1"
"github.com/prebid/openrtb/v20/native1"
)

// 4.4 Image Object
Expand Down
2 changes: 1 addition & 1 deletion native1/request/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ package request
import (
"encoding/json"

"github.com/prebid/openrtb/v19/native1"
"github.com/prebid/openrtb/v20/native1"
)

// 4.1 Native Markup Request Object
Expand Down
2 changes: 1 addition & 1 deletion native1/request/request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"io/ioutil"
"path/filepath"

. "github.com/prebid/openrtb/v19/native1/request"
. "github.com/prebid/openrtb/v20/native1/request"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
Expand Down
2 changes: 1 addition & 1 deletion native1/request/video.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package request

import (
"github.com/prebid/openrtb/v19/openrtb2"
"github.com/prebid/openrtb/v20/openrtb2"
)

// 4.5 Video Object
Expand Down
2 changes: 1 addition & 1 deletion native1/response/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# native1/response [![GoDoc](https://godoc.org/github.com/prebid/openrtb/native1/response?status.svg)](https://pkg.go.dev/github.com/prebid/openrtb/v19/native1/response)
# native1/response [![GoDoc](https://godoc.org/github.com/prebid/openrtb/native1/response?status.svg)](https://pkg.go.dev/github.com/prebid/openrtb/v20/native1/response)

[OpenRTB Dynamic Native Ads API](https://iabtechlab.com/standards/openrtb-native/) [1.2](https://iabtechlab.com/wp-content/uploads/2016/07/OpenRTB-Native-Ads-Specification-Final-1.2.pdf) section "5 Native Ad Response Markup Details" types for [Go programming language](https://golang.org/)
2 changes: 1 addition & 1 deletion native1/response/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package response
import (
"encoding/json"

"github.com/prebid/openrtb/v19/native1"
"github.com/prebid/openrtb/v20/native1"
)

// 5.5 Object: Data
Expand Down
2 changes: 1 addition & 1 deletion native1/response/event_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package response
import (
"encoding/json"

"github.com/prebid/openrtb/v19/native1"
"github.com/prebid/openrtb/v20/native1"
)

// 5.8 Event Tracker Response Object
Expand Down
2 changes: 1 addition & 1 deletion native1/response/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package response
import (
"encoding/json"

"github.com/prebid/openrtb/v19/native1"
"github.com/prebid/openrtb/v20/native1"
)

// 5.4 Object: Image
Expand Down
2 changes: 1 addition & 1 deletion native1/response/response_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"io/ioutil"
"path/filepath"

. "github.com/prebid/openrtb/v19/native1/response"
. "github.com/prebid/openrtb/v20/native1/response"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
Expand Down
2 changes: 1 addition & 1 deletion openrtb2/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# openrtb2 [![GoDoc](https://godoc.org/github.com/prebid/openrtb/openrtb2?status.svg)](https://pkg.go.dev/github.com/prebid/openrtb/v19/openrtb2)
# openrtb2 [![GoDoc](https://godoc.org/github.com/prebid/openrtb/openrtb2?status.svg)](https://pkg.go.dev/github.com/prebid/openrtb/v20/openrtb2)

[OpenRTB](https://iabtechlab.com/standards/openrtb/) [2.6](https://iabtechlab.com/wp-content/uploads/2022/04/OpenRTB-2-6_FINAL.pdf) types for [Go programming language](https://golang.org/)
6 changes: 3 additions & 3 deletions openrtb2/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package openrtb2
import (
"encoding/json"

"github.com/prebid/openrtb/v19/adcom1"
"github.com/prebid/openrtb/v20/adcom1"
)

// Object: App
Expand Down Expand Up @@ -111,15 +111,15 @@ type App struct {
// integer
// Description:
// Indicates if the app has a privacy policy, where 0 = no, 1 = yes.
PrivacyPolicy int8 `json:"privacypolicy,omitempty"`
PrivacyPolicy *int8 `json:"privacypolicy,omitempty"`

// Attribute:
// paid
// Type:
// integer
// Description:
// 0 = app is free, 1 = the app is a paid version.
Paid int8 `json:"paid,omitempty"`
Paid *int8 `json:"paid,omitempty"`

// Attribute:
// publisher
Expand Down
8 changes: 4 additions & 4 deletions openrtb2/audio.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package openrtb2
import (
"encoding/json"

"github.com/prebid/openrtb/v19/adcom1"
"github.com/prebid/openrtb/v20/adcom1"
)

// 3.2.8 Object: Audio
Expand Down Expand Up @@ -170,15 +170,15 @@ type Audio struct {
// Type:
// integer
// Description:
// Minimum bit rate in Kbps.
// Minimum bit rate in Kbps (kilobits per second).
MinBitrate int64 `json:"minbitrate,omitempty"`

// Attribute:
// maxbitrate
// Type:
// integer
// Description:
// Maximum bit rate in Kbps.
// Maximum bit rate in Kbps (kilobits per second).
MaxBitrate int64 `json:"maxbitrate,omitempty"`

// Attribute:
Expand Down Expand Up @@ -245,7 +245,7 @@ type Audio struct {
// Description:
// Indicates if the ad is stitched with audio content or delivered
// independently, where 0 = no, 1 = yes.
Stitched int8 `json:"stitched,omitempty"`
Stitched *int8 `json:"stitched,omitempty"`

// Attribute:
// nvol
Expand Down
4 changes: 2 additions & 2 deletions openrtb2/banner.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package openrtb2
import (
"encoding/json"

"github.com/prebid/openrtb/v19/adcom1"
"github.com/prebid/openrtb/v20/adcom1"
)

// 3.2.6 Object: Banner
Expand Down Expand Up @@ -170,7 +170,7 @@ type Banner struct {
// (Section 3.2.7) in an array of companion ads. Indicates the
// companion banner rendering mode relative to the associated
// video, where 0 = concurrent, 1 = end-card.
VCm int8 `json:"vcm,omitempty"`
Vcm *int8 `json:"vcm,omitempty"`

// Attribute:
// ext
Expand Down
2 changes: 1 addition & 1 deletion openrtb2/bid.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package openrtb2
import (
"encoding/json"

"github.com/prebid/openrtb/v19/adcom1"
"github.com/prebid/openrtb/v20/adcom1"
)

// 4.3.3 Object: Bid
Expand Down
2 changes: 1 addition & 1 deletion openrtb2/bid_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package openrtb2
import (
"encoding/json"

"github.com/prebid/openrtb/v19/adcom1"
"github.com/prebid/openrtb/v20/adcom1"
)

// 3.2.1 Object: BidRequest
Expand Down
2 changes: 1 addition & 1 deletion openrtb2/bid_request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"io/ioutil"
"path/filepath"

. "github.com/prebid/openrtb/v19/openrtb2"
. "github.com/prebid/openrtb/v20/openrtb2"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
Expand Down
2 changes: 1 addition & 1 deletion openrtb2/bid_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package openrtb2
import (
"encoding/json"

"github.com/prebid/openrtb/v19/openrtb3"
"github.com/prebid/openrtb/v20/openrtb3"
)

// 4.3.1 Object: BidResponse
Expand Down
2 changes: 1 addition & 1 deletion openrtb2/bid_response_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"io/ioutil"
"path/filepath"

. "github.com/prebid/openrtb/v19/openrtb2"
. "github.com/prebid/openrtb/v20/openrtb2"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
Expand Down
8 changes: 4 additions & 4 deletions openrtb2/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package openrtb2
import (
"encoding/json"

"github.com/prebid/openrtb/v19/adcom1"
"github.com/prebid/openrtb/v20/adcom1"
)

// 3.2.16 Object: Content
Expand Down Expand Up @@ -205,15 +205,15 @@ type Content struct {
// integer
// Description:
// 0 = not live, 1 = content is live (e.g., stream, live blog).
LiveStream int8 `json:"livestream,omitempty"`
LiveStream *int8 `json:"livestream,omitempty"`

// Attribute:
// sourcerelationship
// Type:
// integer
// Description:
// 0 = indirect, 1 = direct.
SourceRelationship int8 `json:"sourcerelationship,omitempty"`
SourceRelationship *int8 `json:"sourcerelationship,omitempty"`

// Attribute:
// len
Expand Down Expand Up @@ -248,7 +248,7 @@ type Content struct {
// Description:
// Indicator of whether or not the content is embeddable (e.g.,
// an embeddable video player), where 0 = no, 1 = yes.
Embeddable int8 `json:"embeddable,omitempty"`
Embeddable *int8 `json:"embeddable,omitempty"`

// Attribute:
// data
Expand Down
6 changes: 3 additions & 3 deletions openrtb2/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package openrtb2
import (
"encoding/json"

"github.com/prebid/openrtb/v19/adcom1"
"github.com/prebid/openrtb/v20/adcom1"
)

// 3.2.18 Object: Device
Expand Down Expand Up @@ -186,7 +186,7 @@ type Device struct {
// integer
// Description:
// Support for JavaScript, where 0 = no, 1 = yes.
JS int8 `json:"js,omitempty"`
JS *int8 `json:"js,omitempty"`

// Attribute:
// geofetch
Expand All @@ -195,7 +195,7 @@ type Device struct {
// Description:
// Indicates if the geolocation API will be available to JavaScript
// code running in the banner, where 0 = no, 1 = yes.
GeoFetch int8 `json:"geofetch,omitempty"`
GeoFetch *int8 `json:"geofetch,omitempty"`

// Attribute:
// flashver
Expand Down
2 changes: 1 addition & 1 deletion openrtb2/dooh.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package openrtb2
import (
"encoding/json"

"github.com/prebid/openrtb/v19/adcom1"
"github.com/prebid/openrtb/v20/adcom1"
)

// Object: DOOH
Expand Down
Loading
Loading