- Upgrade schema

- Add constants
- Add default
- Add set default for request payload
- Fixes
This commit is contained in:
Aleksandr Garin 2023-08-22 17:46:51 +03:00
parent d713dab392
commit fb9fd9880e
17 changed files with 3775 additions and 1186 deletions

2
Makefile Normal file
View File

@ -0,0 +1,2 @@
generate:
go generate ./...

View File

@ -5,10 +5,11 @@ info:
description: For generate API REST clients for Feelter UGC description: For generate API REST clients for Feelter UGC
contact: contact:
email: garin1221@yandex.ru email: garin1221@yandex.ru
version: 1.0.0 version: 0.0.2
servers: servers:
- url: https://www.youtubekids.com/youtubei/v1 - url: https://www.youtubekids.com/youtubei/v1
description: Original YoutubeKids API Server V1
tags: tags:
- name: browse - name: browse
@ -37,8 +38,8 @@ paths:
'application/json': 'application/json':
"schema": "schema":
$ref: '#/components/schemas/BrowseResponsePayload' $ref: '#/components/schemas/BrowseResponsePayload'
'400': default:
description: Bad Request description: Unexpected error
content: content:
'application/json': 'application/json':
"schema": "schema":
@ -52,6 +53,8 @@ components:
# Ошибка # Ошибка
Error: Error:
type: object type: object
required:
- message
properties: properties:
message: message:
type: string type: string
@ -104,6 +107,8 @@ components:
# Текст -> Runs # Текст -> Runs
TextRun: TextRun:
type: object type: object
required:
- text
properties: properties:
text: text:
type: string type: string
@ -113,6 +118,8 @@ components:
# Текст # Текст
Text: Text:
type: object type: object
required:
- runs
properties: properties:
runs: runs:
type: array type: array
@ -124,6 +131,9 @@ components:
# Строковый параметр ключ-зачение # Строковый параметр ключ-зачение
KeyStringValue: KeyStringValue:
type: object type: object
required:
- key
- value
properties: properties:
key: key:
type: string type: string
@ -133,6 +143,8 @@ components:
# Ассеты категории # Ассеты категории
CategoryAssets: CategoryAssets:
type: object type: object
required:
- assetKey
properties: properties:
assetKey: assetKey:
type: string type: string
@ -142,6 +154,8 @@ components:
# Расширение для владельцев детских видео # Расширение для владельцев детских видео
KidsVideoOwnerExtension: KidsVideoOwnerExtension:
type: object type: object
required:
- externalChannelId
properties: properties:
externalChannelId: externalChannelId:
type: string type: string
@ -149,17 +163,27 @@ components:
# Thumbnail # Thumbnail
Thumbnail: Thumbnail:
type: object type: object
required:
- url
- width
- height
properties: properties:
url: url:
type: string type: string
width: width:
type: number type: integer
height: height:
type: number type: integer
# Компактный видеорендерер # Рендер карточки с видео
CompactVideoRenderer: CompactVideoRenderer:
type: object type: object
required:
- videoId
- title
- viewCountText
- trackingParams
- kidsVideoOwnerExtension
properties: properties:
videoId: videoId:
type: string type: string
@ -200,15 +224,107 @@ components:
kidsVideoOwnerExtension: kidsVideoOwnerExtension:
$ref: '#/components/schemas/KidsVideoOwnerExtension' $ref: '#/components/schemas/KidsVideoOwnerExtension'
# Рендер карточки с плейлистом
CompactPlaylistRenderer:
type: object
required:
- playlistId
- title
- viewCountText
- trackingParams
properties:
playlistId:
type: string
thumbnail:
type: object
properties:
thumbnails:
type: array
items:
$ref: '#/components/schemas/Thumbnail'
title:
$ref: '#/components/schemas/Text'
shortBylineText:
$ref: '#/components/schemas/Text'
videoCountText:
$ref: '#/components/schemas/Text'
navigationEndpoint:
$ref: '#/components/schemas/NavigationEndpoint'
videoCountShortText:
$ref: '#/components/schemas/Text'
trackingParams:
type: string
sidebarThumbnails:
type: array
items:
type: object
properties:
thumbnails:
type: array
items:
$ref: '#/components/schemas/Thumbnail'
thumbnailText:
$ref: '#/components/schemas/Text'
shareUrl:
type: string
longBylineText:
$ref: '#/components/schemas/Text'
tvBanner:
type: object
properties:
thumbnails:
type: array
items:
$ref: '#/components/schemas/Thumbnail'
# Рендер карточки с каналом
CompactChannelRenderer:
type: object
required:
- channelId
- displayName
- videoCountText
- title
- trackingParams
properties:
channelId:
type: string
thumbnail:
type: object
properties:
thumbnails:
type: array
items:
$ref: '#/components/schemas/Thumbnail'
displayName:
$ref: '#/components/schemas/Text'
videoCountText:
$ref: '#/components/schemas/Text'
subscriberCountText:
$ref: '#/components/schemas/Text'
navigationEndpoint:
$ref: '#/components/schemas/NavigationEndpoint'
title:
$ref: '#/components/schemas/Text'
trackingParams:
type: string
# Средство визуализации раздела элемента # Средство визуализации раздела элемента
ItemSectionRenderer: ItemSectionRenderer:
type: object type: object
required:
- contents
- trackingParams
properties: properties:
contents: contents:
type: array type: array
items: items:
type: object type: object
properties: properties:
compactPlaylistRenderer:
$ref: '#/components/schemas/CompactPlaylistRenderer'
compactChannelRenderer:
$ref: '#/components/schemas/CompactChannelRenderer'
compactVideoRenderer: compactVideoRenderer:
$ref: '#/components/schemas/CompactVideoRenderer' $ref: '#/components/schemas/CompactVideoRenderer'
trackingParams: trackingParams:
@ -275,13 +391,29 @@ components:
# Параметры контента # Параметры контента
KidsAppContentSettings: KidsAppContentSettings:
type: object type: object
required:
- corpusPreference
- kidsNoSearchMode
properties: properties:
corpusPreference: corpusPreference:
type: string type: string
enum:
- KIDS_CORPUS_PREFERENCE_UNKNOWN # unknown
- KIDS_CORPUS_PREFERENCE_YOUNGER # (0-4 years)
- KIDS_CORPUS_PREFERENCE_TWEEN # (5-7)
- KIDS_CORPUS_PREFERENCE_PAM_YOUNGER
- KIDS_CORPUS_PREFERENCE_PAM_TWEEN
- KIDS_CORPUS_PREFERENCE_PRESCHOOL # (8-12)
example: KIDS_CORPUS_PREFERENCE_TWEEN example: KIDS_CORPUS_PREFERENCE_TWEEN
default: KIDS_CORPUS_PREFERENCE_TWEEN
kidsNoSearchMode: kidsNoSearchMode:
type: string type: string
enum:
- YT_KIDS_NO_SEARCH_MODE_UNKNOWN # unknown
- YT_KIDS_NO_SEARCH_MODE_ON
- YT_KIDS_NO_SEARCH_MODE_OFF
example: YT_KIDS_NO_SEARCH_MODE_OFF example: YT_KIDS_NO_SEARCH_MODE_OFF
default: YT_KIDS_NO_SEARCH_MODE_OFF
# Конфигурация категорий # Конфигурация категорий
KidsAppCategorySettings: KidsAppCategorySettings:
@ -307,39 +439,51 @@ components:
RequestClient: RequestClient:
type: object type: object
description: Client information description: Client information
required:
- kidsAppInfo
properties: properties:
clientName: clientName:
type: string type: string
example: WEB_KIDS example: WEB_KIDS
default: WEB_KIDS
clientVersion: clientVersion:
type: string type: string
example: 2.20230202.00.00 example: 2.20230817.00.00
default: 2.20230817.00.00
hl: hl:
type: string type: string
example: ru example: ru
default: ru
gl: gl:
type: string type: string
example: RU example: RU
default: RU
experimentsToken: experimentsToken:
type: string type: string
browserName: browserName:
type: string type: string
example: Safari example: Safari
default: Safari
deviceMake: deviceMake:
type: string type: string
example: apple example: apple
default: apple
browserVersion: browserVersion:
type: string type: string
example: '16.2' example: '16.2'
default: '16.2'
osName: osName:
type: string type: string
example: Macintosh example: Macintosh
default: Macintosh
osVersion: osVersion:
type: string type: string
example: 10_15_7 example: '10_15_7'
default: '10_15_7'
platform: platform:
type: string type: string
example: DESKTOP example: DESKTOP
default: DESKTOP
kidsAppInfo: kidsAppInfo:
$ref: '#/components/schemas/KidsAppInfo' $ref: '#/components/schemas/KidsAppInfo'
@ -347,6 +491,8 @@ components:
RequestContext: RequestContext:
type: object type: object
description: Request context description: Request context
required:
- client
properties: properties:
client: client:
$ref: '#/components/schemas/RequestClient' $ref: '#/components/schemas/RequestClient'
@ -359,7 +505,7 @@ components:
visitorData: visitorData:
type: string type: string
maxAgeSeconds: maxAgeSeconds:
type: number type: integer
serviceTrackingParams: serviceTrackingParams:
type: array type: array
items: items:
@ -375,9 +521,14 @@ components:
# Данные для запроса на получение контента определенного ресурса # Данные для запроса на получение контента определенного ресурса
BrowseRequestPayload: BrowseRequestPayload:
type: object type: object
required:
- context
- browseId
properties: properties:
context: context:
$ref: '#/components/schemas/RequestContext' $ref: '#/components/schemas/RequestContext'
params:
type: string
browseId: browseId:
type: string type: string
example: FEkids_home example: FEkids_home
@ -385,6 +536,10 @@ components:
# Ответ на запрос получения контента определенного ресурса # Ответ на запрос получения контента определенного ресурса
BrowseResponsePayload: BrowseResponsePayload:
type: object type: object
required:
- header
- contents
- responseContext
properties: properties:
responseContext: responseContext:
$ref: '#/components/schemas/ResponseContext' $ref: '#/components/schemas/ResponseContext'
@ -404,12 +559,18 @@ components:
# Ответ с ошибкой # Ответ с ошибкой
ErrorResponsePayload: ErrorResponsePayload:
type: object type: object
required:
- error
properties: properties:
error: error:
type: object type: object
required:
- code
- status
- message
properties: properties:
code: code:
type: number type: integer
example: 400 example: 400
message: message:
type: string type: string

View File

@ -0,0 +1,9 @@
package go_youtubekids_client
func (p *BrowseRequestPayload) SetDefaults() *BrowseRequestPayload {
p.Context.Client.setDefaults()
if p.Context.Client.KidsAppInfo.ContentSettings.Set {
p.Context.Client.KidsAppInfo.ContentSettings.Value.setDefaults()
}
return p
}

5
constants.go Normal file
View File

@ -0,0 +1,5 @@
package go_youtubekids_client
const DefaultServerURL = "https://www.youtubekids.com/youtubei/v1"
const BrowseIdForKidsHome = "FEkids_home"

29
examples/browse/main.go Normal file
View File

@ -0,0 +1,29 @@
package main
import (
"context"
"encoding/json"
youtubekids "githouse.ru/feelter-ugc/go-youtubekids-client"
"log"
)
func main() {
client, err := youtubekids.NewClient(youtubekids.DefaultServerURL)
if err != nil {
panic(err)
}
response, err := client.Browse(context.TODO(), (&youtubekids.BrowseRequestPayload{
BrowseId: youtubekids.BrowseIdForKidsHome,
Context: youtubekids.RequestContext{
Client: youtubekids.RequestClient{},
},
}).SetDefaults())
if err != nil {
panic(err)
}
data, err := json.MarshalIndent(response, "", " ")
if err != nil {
panic(err)
}
log.Println(string(data))
}

View File

@ -1,3 +1,7 @@
package go_youtubekids_client package go_youtubekids_client
import (
_ "github.com/ogen-go/ogen/gen"
)
//go:generate go run github.com/ogen-go/ogen/cmd/ogen -target . -clean -generate-tests -no-server -no-webhook-server -no-webhook-client -package go_youtubekids_client ./api/swagger.yaml //go:generate go run github.com/ogen-go/ogen/cmd/ogen -target . -clean -generate-tests -no-server -no-webhook-server -no-webhook-client -package go_youtubekids_client ./api/swagger.yaml

4
go.mod
View File

@ -6,12 +6,14 @@ require (
github.com/go-faster/errors v0.6.1 github.com/go-faster/errors v0.6.1
github.com/go-faster/jx v1.0.0 github.com/go-faster/jx v1.0.0
github.com/ogen-go/ogen v0.61.0 github.com/ogen-go/ogen v0.61.0
github.com/stretchr/testify v1.8.2
go.opentelemetry.io/otel v1.14.0 go.opentelemetry.io/otel v1.14.0
go.opentelemetry.io/otel/metric v0.37.0 go.opentelemetry.io/otel/metric v0.37.0
go.opentelemetry.io/otel/trace v1.14.0 go.opentelemetry.io/otel/trace v1.14.0
) )
require ( require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dlclark/regexp2 v1.8.1 // indirect github.com/dlclark/regexp2 v1.8.1 // indirect
github.com/fatih/color v1.15.0 // indirect github.com/fatih/color v1.15.0 // indirect
github.com/ghodss/yaml v1.0.0 // indirect github.com/ghodss/yaml v1.0.0 // indirect
@ -21,6 +23,7 @@ require (
github.com/google/uuid v1.3.0 // indirect github.com/google/uuid v1.3.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.18 // indirect github.com/mattn/go-isatty v0.0.18 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/segmentio/asm v1.2.0 // indirect github.com/segmentio/asm v1.2.0 // indirect
go.uber.org/atomic v1.10.0 // indirect go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect
@ -33,4 +36,5 @@ require (
golang.org/x/text v0.8.0 // indirect golang.org/x/text v0.8.0 // indirect
golang.org/x/tools v0.7.0 // indirect golang.org/x/tools v0.7.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
) )

11
go.sum
View File

@ -1,5 +1,7 @@
github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dlclark/regexp2 v1.8.1 h1:6Lcdwya6GjPUNsBct8Lg/yRPwMhABj269AAzdGSiR+0= github.com/dlclark/regexp2 v1.8.1 h1:6Lcdwya6GjPUNsBct8Lg/yRPwMhABj269AAzdGSiR+0=
github.com/dlclark/regexp2 v1.8.1/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/dlclark/regexp2 v1.8.1/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
@ -31,9 +33,16 @@ github.com/ogen-go/ogen v0.61.0 h1:U3hkx9ydCL2tb0055ut0o8hWaEOWCs2+rG2rpwCMGPM=
github.com/ogen-go/ogen v0.61.0/go.mod h1:Rn43MIqVcT8utwLi45lv7e/a4kPRk+klLsWsgB1z9GQ= github.com/ogen-go/ogen v0.61.0/go.mod h1:Rn43MIqVcT8utwLi45lv7e/a4kPRk+klLsWsgB1z9GQ=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys= github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys=
github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs= github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
go.opentelemetry.io/otel v1.14.0 h1:/79Huy8wbf5DnIPhemGB+zEPVwnN6fuQybr/SRXa6hM= go.opentelemetry.io/otel v1.14.0 h1:/79Huy8wbf5DnIPhemGB+zEPVwnN6fuQybr/SRXa6hM=
go.opentelemetry.io/otel v1.14.0/go.mod h1:o4buv+dJzx8rohcUeRmWUZhqupFvzWis188WlggnNeU= go.opentelemetry.io/otel v1.14.0/go.mod h1:o4buv+dJzx8rohcUeRmWUZhqupFvzWis188WlggnNeU=
go.opentelemetry.io/otel/metric v0.37.0 h1:pHDQuLQOZwYD+Km0eb657A25NaRzy0a+eLyKfDXedEs= go.opentelemetry.io/otel/metric v0.37.0 h1:pHDQuLQOZwYD+Km0eb657A25NaRzy0a+eLyKfDXedEs=
@ -66,4 +75,6 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View File

@ -67,16 +67,25 @@ func (c *Client) requestURL(ctx context.Context) *url.URL {
// Get content for resource. // Get content for resource.
// //
// POST /browse // POST /browse
func (c *Client) Browse(ctx context.Context, request *BrowseRequestPayload) (BrowseRes, error) { func (c *Client) Browse(ctx context.Context, request *BrowseRequestPayload) (*BrowseResponsePayload, error) {
res, err := c.sendBrowse(ctx, request) res, err := c.sendBrowse(ctx, request)
_ = res _ = res
return res, err return res, err
} }
func (c *Client) sendBrowse(ctx context.Context, request *BrowseRequestPayload) (res BrowseRes, err error) { func (c *Client) sendBrowse(ctx context.Context, request *BrowseRequestPayload) (res *BrowseResponsePayload, err error) {
otelAttrs := []attribute.KeyValue{ otelAttrs := []attribute.KeyValue{
otelogen.OperationID("browse"), otelogen.OperationID("browse"),
} }
// Validate request before sending.
if err := func() error {
if err := request.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return res, errors.Wrap(err, "validate")
}
// Run stopwatch. // Run stopwatch.
startTime := time.Now() startTime := time.Now()

59
oas_defaults_gen.go Normal file
View File

@ -0,0 +1,59 @@
// Code generated by ogen, DO NOT EDIT.
package go_youtubekids_client
// setDefaults set default value of fields.
func (s *KidsAppContentSettings) setDefaults() {
{
val := KidsAppContentSettingsCorpusPreference("KIDS_CORPUS_PREFERENCE_TWEEN")
s.CorpusPreference = val
}
{
val := KidsAppContentSettingsKidsNoSearchMode("YT_KIDS_NO_SEARCH_MODE_OFF")
s.KidsNoSearchMode = val
}
}
// setDefaults set default value of fields.
func (s *RequestClient) setDefaults() {
{
val := string("WEB_KIDS")
s.ClientName.SetTo(val)
}
{
val := string("2.20230817.00.00")
s.ClientVersion.SetTo(val)
}
{
val := string("ru")
s.Hl.SetTo(val)
}
{
val := string("RU")
s.Gl.SetTo(val)
}
{
val := string("Safari")
s.BrowserName.SetTo(val)
}
{
val := string("apple")
s.DeviceMake.SetTo(val)
}
{
val := string("16.2")
s.BrowserVersion.SetTo(val)
}
{
val := string("Macintosh")
s.OsName.SetTo(val)
}
{
val := string("10_15_7")
s.OsVersion.SetTo(val)
}
{
val := string("DESKTOP")
s.Platform.SetTo(val)
}
}

View File

@ -86,7 +86,12 @@ func (s *BrowseRequestPayload) SetFake() {
} }
{ {
{ {
s.BrowseId.SetFake() s.Params.SetFake()
}
}
{
{
s.BrowseId = "string"
} }
} }
} }
@ -146,7 +151,7 @@ func (s *CategoriesHeaderRenderer) SetFake() {
func (s *CategoryAssets) SetFake() { func (s *CategoryAssets) SetFake() {
{ {
{ {
s.AssetKey.SetFake() s.AssetKey = "string"
} }
} }
{ {
@ -156,11 +161,195 @@ func (s *CategoryAssets) SetFake() {
} }
} }
// SetFake set fake values.
func (s *CompactChannelRenderer) SetFake() {
{
{
s.ChannelId = "string"
}
}
{
{
s.Thumbnail.SetFake()
}
}
{
{
s.DisplayName.SetFake()
}
}
{
{
s.VideoCountText.SetFake()
}
}
{
{
s.SubscriberCountText.SetFake()
}
}
{
{
s.NavigationEndpoint.SetFake()
}
}
{
{
s.Title.SetFake()
}
}
{
{
s.TrackingParams = "string"
}
}
}
// SetFake set fake values.
func (s *CompactChannelRendererThumbnail) SetFake() {
{
{
s.Thumbnails = nil
for i := 0; i < 0; i++ {
var elem Thumbnail
{
elem.SetFake()
}
s.Thumbnails = append(s.Thumbnails, elem)
}
}
}
}
// SetFake set fake values.
func (s *CompactPlaylistRenderer) SetFake() {
{
{
s.PlaylistId = "string"
}
}
{
{
s.Thumbnail.SetFake()
}
}
{
{
s.Title.SetFake()
}
}
{
{
s.ShortBylineText.SetFake()
}
}
{
{
s.VideoCountText.SetFake()
}
}
{
{
s.NavigationEndpoint.SetFake()
}
}
{
{
s.VideoCountShortText.SetFake()
}
}
{
{
s.TrackingParams = "string"
}
}
{
{
s.SidebarThumbnails = nil
for i := 0; i < 0; i++ {
var elem CompactPlaylistRendererSidebarThumbnailsItem
{
elem.SetFake()
}
s.SidebarThumbnails = append(s.SidebarThumbnails, elem)
}
}
}
{
{
s.ThumbnailText.SetFake()
}
}
{
{
s.ShareUrl.SetFake()
}
}
{
{
s.LongBylineText.SetFake()
}
}
{
{
s.TvBanner.SetFake()
}
}
}
// SetFake set fake values.
func (s *CompactPlaylistRendererSidebarThumbnailsItem) SetFake() {
{
{
s.Thumbnails = nil
for i := 0; i < 0; i++ {
var elem Thumbnail
{
elem.SetFake()
}
s.Thumbnails = append(s.Thumbnails, elem)
}
}
}
}
// SetFake set fake values.
func (s *CompactPlaylistRendererThumbnail) SetFake() {
{
{
s.Thumbnails = nil
for i := 0; i < 0; i++ {
var elem Thumbnail
{
elem.SetFake()
}
s.Thumbnails = append(s.Thumbnails, elem)
}
}
}
}
// SetFake set fake values.
func (s *CompactPlaylistRendererTvBanner) SetFake() {
{
{
s.Thumbnails = nil
for i := 0; i < 0; i++ {
var elem Thumbnail
{
elem.SetFake()
}
s.Thumbnails = append(s.Thumbnails, elem)
}
}
}
}
// SetFake set fake values. // SetFake set fake values.
func (s *CompactVideoRenderer) SetFake() { func (s *CompactVideoRenderer) SetFake() {
{ {
{ {
s.VideoId.SetFake() s.VideoId = "string"
} }
} }
{ {
@ -210,7 +399,7 @@ func (s *CompactVideoRenderer) SetFake() {
} }
{ {
{ {
s.TrackingParams.SetFake() s.TrackingParams = "string"
} }
} }
{ {
@ -266,7 +455,7 @@ func (s *CompactVideoRendererThumbnail) SetFake() {
func (s *Error) SetFake() { func (s *Error) SetFake() {
{ {
{ {
s.Message.SetFake() s.Message = "string"
} }
} }
{ {
@ -294,12 +483,12 @@ func (s *ErrorResponsePayload) SetFake() {
func (s *ErrorResponsePayloadError) SetFake() { func (s *ErrorResponsePayloadError) SetFake() {
{ {
{ {
s.Code.SetFake() s.Code = int(0)
} }
} }
{ {
{ {
s.Message.SetFake() s.Message = "string"
} }
} }
{ {
@ -316,7 +505,7 @@ func (s *ErrorResponsePayloadError) SetFake() {
} }
{ {
{ {
s.Status.SetFake() s.Status = "string"
} }
} }
} }
@ -337,13 +526,23 @@ func (s *ItemSectionRenderer) SetFake() {
} }
{ {
{ {
s.TrackingParams.SetFake() s.TrackingParams = "string"
} }
} }
} }
// SetFake set fake values. // SetFake set fake values.
func (s *ItemSectionRendererContentsItem) SetFake() { func (s *ItemSectionRendererContentsItem) SetFake() {
{
{
s.CompactPlaylistRenderer.SetFake()
}
}
{
{
s.CompactChannelRenderer.SetFake()
}
}
{ {
{ {
s.CompactVideoRenderer.SetFake() s.CompactVideoRenderer.SetFake()
@ -355,12 +554,12 @@ func (s *ItemSectionRendererContentsItem) SetFake() {
func (s *KeyStringValue) SetFake() { func (s *KeyStringValue) SetFake() {
{ {
{ {
s.Key.SetFake() s.Key = "string"
} }
} }
{ {
{ {
s.Value.SetFake() s.Value = "string"
} }
} }
} }
@ -395,6 +594,16 @@ func (s *KidsAppContentSettings) SetFake() {
} }
} }
// SetFake set fake values.
func (s *KidsAppContentSettingsCorpusPreference) SetFake() {
*s = KidsAppContentSettingsCorpusPreferenceKIDSCORPUSPREFERENCEUNKNOWN
}
// SetFake set fake values.
func (s *KidsAppContentSettingsKidsNoSearchMode) SetFake() {
*s = KidsAppContentSettingsKidsNoSearchModeYTKIDSNOSEARCHMODEUNKNOWN
}
// SetFake set fake values. // SetFake set fake values.
func (s *KidsAppInfo) SetFake() { func (s *KidsAppInfo) SetFake() {
{ {
@ -413,7 +622,7 @@ func (s *KidsAppInfo) SetFake() {
func (s *KidsVideoOwnerExtension) SetFake() { func (s *KidsVideoOwnerExtension) SetFake() {
{ {
{ {
s.ExternalChannelId.SetFake() s.ExternalChannelId = "string"
} }
} }
} }
@ -482,24 +691,6 @@ func (s *OptBrowseEndpoint) SetFake() {
s.SetTo(elem) s.SetTo(elem)
} }
// SetFake set fake values.
func (s *OptBrowseResponsePayloadContents) SetFake() {
var elem BrowseResponsePayloadContents
{
elem.SetFake()
}
s.SetTo(elem)
}
// SetFake set fake values.
func (s *OptBrowseResponsePayloadHeader) SetFake() {
var elem BrowseResponsePayloadHeader
{
elem.SetFake()
}
s.SetTo(elem)
}
// SetFake set fake values. // SetFake set fake values.
func (s *OptCategoriesHeaderRenderer) SetFake() { func (s *OptCategoriesHeaderRenderer) SetFake() {
var elem CategoriesHeaderRenderer var elem CategoriesHeaderRenderer
@ -518,6 +709,51 @@ func (s *OptCategoryAssets) SetFake() {
s.SetTo(elem) s.SetTo(elem)
} }
// SetFake set fake values.
func (s *OptCompactChannelRenderer) SetFake() {
var elem CompactChannelRenderer
{
elem.SetFake()
}
s.SetTo(elem)
}
// SetFake set fake values.
func (s *OptCompactChannelRendererThumbnail) SetFake() {
var elem CompactChannelRendererThumbnail
{
elem.SetFake()
}
s.SetTo(elem)
}
// SetFake set fake values.
func (s *OptCompactPlaylistRenderer) SetFake() {
var elem CompactPlaylistRenderer
{
elem.SetFake()
}
s.SetTo(elem)
}
// SetFake set fake values.
func (s *OptCompactPlaylistRendererThumbnail) SetFake() {
var elem CompactPlaylistRendererThumbnail
{
elem.SetFake()
}
s.SetTo(elem)
}
// SetFake set fake values.
func (s *OptCompactPlaylistRendererTvBanner) SetFake() {
var elem CompactPlaylistRendererTvBanner
{
elem.SetFake()
}
s.SetTo(elem)
}
// SetFake set fake values. // SetFake set fake values.
func (s *OptCompactVideoRenderer) SetFake() { func (s *OptCompactVideoRenderer) SetFake() {
var elem CompactVideoRenderer var elem CompactVideoRenderer
@ -546,19 +782,10 @@ func (s *OptCompactVideoRendererThumbnail) SetFake() {
} }
// SetFake set fake values. // SetFake set fake values.
func (s *OptErrorResponsePayloadError) SetFake() { func (s *OptInt) SetFake() {
var elem ErrorResponsePayloadError var elem int
{ {
elem.SetFake() elem = int(0)
}
s.SetTo(elem)
}
// SetFake set fake values.
func (s *OptFloat64) SetFake() {
var elem float64
{
elem = float64(0)
} }
s.SetTo(elem) s.SetTo(elem)
} }
@ -590,24 +817,6 @@ func (s *OptKidsAppContentSettings) SetFake() {
s.SetTo(elem) s.SetTo(elem)
} }
// SetFake set fake values.
func (s *OptKidsAppInfo) SetFake() {
var elem KidsAppInfo
{
elem.SetFake()
}
s.SetTo(elem)
}
// SetFake set fake values.
func (s *OptKidsVideoOwnerExtension) SetFake() {
var elem KidsVideoOwnerExtension
{
elem.SetFake()
}
s.SetTo(elem)
}
// SetFake set fake values. // SetFake set fake values.
func (s *OptNavigationEndpoint) SetFake() { func (s *OptNavigationEndpoint) SetFake() {
var elem NavigationEndpoint var elem NavigationEndpoint
@ -617,33 +826,6 @@ func (s *OptNavigationEndpoint) SetFake() {
s.SetTo(elem) s.SetTo(elem)
} }
// SetFake set fake values.
func (s *OptRequestClient) SetFake() {
var elem RequestClient
{
elem.SetFake()
}
s.SetTo(elem)
}
// SetFake set fake values.
func (s *OptRequestContext) SetFake() {
var elem RequestContext
{
elem.SetFake()
}
s.SetTo(elem)
}
// SetFake set fake values.
func (s *OptResponseContext) SetFake() {
var elem ResponseContext
{
elem.SetFake()
}
s.SetTo(elem)
}
// SetFake set fake values. // SetFake set fake values.
func (s *OptScreenRenderer) SetFake() { func (s *OptScreenRenderer) SetFake() {
var elem ScreenRenderer var elem ScreenRenderer
@ -889,7 +1071,7 @@ func (s *Text) SetFake() {
func (s *TextRun) SetFake() { func (s *TextRun) SetFake() {
{ {
{ {
s.Text.SetFake() s.Text = "string"
} }
} }
{ {
@ -903,17 +1085,17 @@ func (s *TextRun) SetFake() {
func (s *Thumbnail) SetFake() { func (s *Thumbnail) SetFake() {
{ {
{ {
s.URL.SetFake() s.URL = "string"
} }
} }
{ {
{ {
s.Width.SetFake() s.Width = int(0)
} }
} }
{ {
{ {
s.Height.SetFake() s.Height = int(0)
} }
} }
} }

View File

@ -1,6 +0,0 @@
// Code generated by ogen, DO NOT EDIT.
package go_youtubekids_client
type BrowseRes interface {
browseRes()
}

File diff suppressed because it is too large Load Diff

View File

@ -14,7 +14,7 @@ import (
"github.com/ogen-go/ogen/validate" "github.com/ogen-go/ogen/validate"
) )
func decodeBrowseResponse(resp *http.Response) (res BrowseRes, err error) { func decodeBrowseResponse(resp *http.Response) (res *BrowseResponsePayload, err error) {
switch resp.StatusCode { switch resp.StatusCode {
case 200: case 200:
// Code 200. // Code 200.
@ -51,8 +51,9 @@ func decodeBrowseResponse(resp *http.Response) (res BrowseRes, err error) {
default: default:
return res, validate.InvalidContentType(ct) return res, validate.InvalidContentType(ct)
} }
case 400: }
// Code 400. // Convenient error response.
defRes, err := func() (res *ErrorResponsePayloadStatusCode, err error) {
ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
if err != nil { if err != nil {
return res, errors.Wrap(err, "parse media type") return res, errors.Wrap(err, "parse media type")
@ -82,10 +83,16 @@ func decodeBrowseResponse(resp *http.Response) (res BrowseRes, err error) {
} }
return res, err return res, err
} }
return &response, nil return &ErrorResponsePayloadStatusCode{
StatusCode: resp.StatusCode,
Response: response,
}, nil
default: default:
return res, validate.InvalidContentType(ct) return res, validate.InvalidContentType(ct)
} }
}()
if err != nil {
return res, errors.Wrap(err, "default")
} }
return res, validate.UnexpectedStatusCode(resp.StatusCode) return res, errors.Wrap(defRes, "error")
} }

File diff suppressed because it is too large Load Diff

View File

@ -3,8 +3,13 @@
package go_youtubekids_client package go_youtubekids_client
import ( import (
"fmt"
"github.com/go-faster/errors"
"github.com/go-faster/jx" "github.com/go-faster/jx"
"github.com/ogen-go/ogen/validate"
std "encoding/json" std "encoding/json"
"testing" "testing"
@ -143,6 +148,78 @@ func TestCategoryAssets_EncodeDecode(t *testing.T) {
var typ2 CategoryAssets var typ2 CategoryAssets
require.NoError(t, typ2.Decode(jx.DecodeBytes(data))) require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
} }
func TestCompactChannelRenderer_EncodeDecode(t *testing.T) {
var typ CompactChannelRenderer
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 CompactChannelRenderer
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestCompactChannelRendererThumbnail_EncodeDecode(t *testing.T) {
var typ CompactChannelRendererThumbnail
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 CompactChannelRendererThumbnail
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestCompactPlaylistRenderer_EncodeDecode(t *testing.T) {
var typ CompactPlaylistRenderer
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 CompactPlaylistRenderer
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestCompactPlaylistRendererSidebarThumbnailsItem_EncodeDecode(t *testing.T) {
var typ CompactPlaylistRendererSidebarThumbnailsItem
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 CompactPlaylistRendererSidebarThumbnailsItem
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestCompactPlaylistRendererThumbnail_EncodeDecode(t *testing.T) {
var typ CompactPlaylistRendererThumbnail
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 CompactPlaylistRendererThumbnail
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestCompactPlaylistRendererTvBanner_EncodeDecode(t *testing.T) {
var typ CompactPlaylistRendererTvBanner
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 CompactPlaylistRendererTvBanner
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestCompactVideoRenderer_EncodeDecode(t *testing.T) { func TestCompactVideoRenderer_EncodeDecode(t *testing.T) {
var typ CompactVideoRenderer var typ CompactVideoRenderer
typ.SetFake() typ.SetFake()
@ -275,6 +352,88 @@ func TestKidsAppContentSettings_EncodeDecode(t *testing.T) {
var typ2 KidsAppContentSettings var typ2 KidsAppContentSettings
require.NoError(t, typ2.Decode(jx.DecodeBytes(data))) require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
} }
func TestKidsAppContentSettingsCorpusPreference_EncodeDecode(t *testing.T) {
var typ KidsAppContentSettingsCorpusPreference
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 KidsAppContentSettingsCorpusPreference
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestKidsAppContentSettingsCorpusPreference_Examples(t *testing.T) {
for i, tc := range []struct {
Input string
}{
{Input: "\"KIDS_CORPUS_PREFERENCE_TWEEN\""},
} {
tc := tc
t.Run(fmt.Sprintf("Test%d", i+1), func(t *testing.T) {
var typ KidsAppContentSettingsCorpusPreference
if err := typ.Decode(jx.DecodeStr(tc.Input)); err != nil {
if validateErr, ok := errors.Into[*validate.Error](err); ok {
t.Skipf("Validation error: %v", validateErr)
return
}
require.NoErrorf(t, err, "Input: %s", tc.Input)
}
e := jx.Encoder{}
typ.Encode(&e)
require.True(t, std.Valid(e.Bytes()), "Encoded: %s", e.Bytes())
var typ2 KidsAppContentSettingsCorpusPreference
require.NoError(t, typ2.Decode(jx.DecodeBytes(e.Bytes())))
})
}
}
func TestKidsAppContentSettingsKidsNoSearchMode_EncodeDecode(t *testing.T) {
var typ KidsAppContentSettingsKidsNoSearchMode
typ.SetFake()
e := jx.Encoder{}
typ.Encode(&e)
data := e.Bytes()
require.True(t, std.Valid(data), "Encoded: %s", data)
var typ2 KidsAppContentSettingsKidsNoSearchMode
require.NoError(t, typ2.Decode(jx.DecodeBytes(data)))
}
func TestKidsAppContentSettingsKidsNoSearchMode_Examples(t *testing.T) {
for i, tc := range []struct {
Input string
}{
{Input: "\"YT_KIDS_NO_SEARCH_MODE_OFF\""},
} {
tc := tc
t.Run(fmt.Sprintf("Test%d", i+1), func(t *testing.T) {
var typ KidsAppContentSettingsKidsNoSearchMode
if err := typ.Decode(jx.DecodeStr(tc.Input)); err != nil {
if validateErr, ok := errors.Into[*validate.Error](err); ok {
t.Skipf("Validation error: %v", validateErr)
return
}
require.NoErrorf(t, err, "Input: %s", tc.Input)
}
e := jx.Encoder{}
typ.Encode(&e)
require.True(t, std.Valid(e.Bytes()), "Encoded: %s", e.Bytes())
var typ2 KidsAppContentSettingsKidsNoSearchMode
require.NoError(t, typ2.Decode(jx.DecodeBytes(e.Bytes())))
})
}
}
func TestKidsAppInfo_EncodeDecode(t *testing.T) { func TestKidsAppInfo_EncodeDecode(t *testing.T) {
var typ KidsAppInfo var typ KidsAppInfo
typ.SetFake() typ.SetFake()

View File

@ -60,36 +60,29 @@ func (s *AnchoredSectionRendererContent) Validate() error {
} }
return nil return nil
} }
func (s *BrowseResponsePayload) Validate() error { func (s *BrowseRequestPayload) Validate() error {
var failures []validate.FieldError var failures []validate.FieldError
if err := func() error { if err := func() error {
if s.ResponseContext.Set { if err := s.Context.Validate(); err != nil {
if err := func() error {
if err := s.ResponseContext.Value.Validate(); err != nil {
return err return err
} }
return nil return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil { }(); err != nil {
failures = append(failures, validate.FieldError{ failures = append(failures, validate.FieldError{
Name: "responseContext", Name: "context",
Error: err, Error: err,
}) })
} }
if err := func() error { if len(failures) > 0 {
if s.Contents.Set { return &validate.Error{Fields: failures}
if err := func() error {
if err := s.Contents.Value.Validate(); err != nil {
return err
} }
return nil return nil
}(); err != nil {
return err
} }
func (s *BrowseResponsePayload) Validate() error {
var failures []validate.FieldError
if err := func() error {
if err := s.Contents.Validate(); err != nil {
return err
} }
return nil return nil
}(); err != nil { }(); err != nil {
@ -128,30 +121,189 @@ func (s *BrowseResponsePayloadContents) Validate() error {
} }
return nil return nil
} }
func (s *CompactChannelRenderer) Validate() error {
var failures []validate.FieldError
if err := func() error {
if err := s.DisplayName.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "displayName",
Error: err,
})
}
if err := func() error {
if err := s.VideoCountText.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "videoCountText",
Error: err,
})
}
if err := func() error {
if s.SubscriberCountText.Set {
if err := func() error {
if err := s.SubscriberCountText.Value.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "subscriberCountText",
Error: err,
})
}
if err := func() error {
if err := s.Title.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "title",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s *CompactPlaylistRenderer) Validate() error {
var failures []validate.FieldError
if err := func() error {
if err := s.Title.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "title",
Error: err,
})
}
if err := func() error {
if s.ShortBylineText.Set {
if err := func() error {
if err := s.ShortBylineText.Value.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "shortBylineText",
Error: err,
})
}
if err := func() error {
if s.VideoCountText.Set {
if err := func() error {
if err := s.VideoCountText.Value.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "videoCountText",
Error: err,
})
}
if err := func() error {
if s.VideoCountShortText.Set {
if err := func() error {
if err := s.VideoCountShortText.Value.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "videoCountShortText",
Error: err,
})
}
if err := func() error {
if s.ThumbnailText.Set {
if err := func() error {
if err := s.ThumbnailText.Value.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "thumbnailText",
Error: err,
})
}
if err := func() error {
if s.LongBylineText.Set {
if err := func() error {
if err := s.LongBylineText.Value.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "longBylineText",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s *CompactVideoRenderer) Validate() error { func (s *CompactVideoRenderer) Validate() error {
var failures []validate.FieldError var failures []validate.FieldError
if err := func() error { if err := func() error {
if s.Thumbnail.Set { if err := s.Title.Validate(); err != nil {
if err := func() error {
if err := s.Thumbnail.Value.Validate(); err != nil {
return err return err
} }
return nil return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil { }(); err != nil {
failures = append(failures, validate.FieldError{ failures = append(failures, validate.FieldError{
Name: "thumbnail", Name: "title",
Error: err, Error: err,
}) })
} }
if err := func() error { if err := func() error {
if s.ChannelThumbnail.Set { if s.LongBylineText.Set {
if err := func() error { if err := func() error {
if err := s.ChannelThumbnail.Value.Validate(); err != nil { if err := s.LongBylineText.Value.Validate(); err != nil {
return err return err
} }
return nil return nil
@ -162,85 +314,14 @@ func (s *CompactVideoRenderer) Validate() error {
return nil return nil
}(); err != nil { }(); err != nil {
failures = append(failures, validate.FieldError{ failures = append(failures, validate.FieldError{
Name: "channelThumbnail", Name: "longBylineText",
Error: err, Error: err,
}) })
} }
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s *CompactVideoRendererChannelThumbnail) Validate() error {
var failures []validate.FieldError
if err := func() error { if err := func() error {
var failures []validate.FieldError if s.PublishedTimeText.Set {
for i, elem := range s.Thumbnails {
if err := func() error { if err := func() error {
if err := elem.Validate(); err != nil { if err := s.PublishedTimeText.Value.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: fmt.Sprintf("[%d]", i),
Error: err,
})
}
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "thumbnails",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s *CompactVideoRendererThumbnail) Validate() error {
var failures []validate.FieldError
if err := func() error {
var failures []validate.FieldError
for i, elem := range s.Thumbnails {
if err := func() error {
if err := elem.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: fmt.Sprintf("[%d]", i),
Error: err,
})
}
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "thumbnails",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s *ErrorResponsePayload) Validate() error {
var failures []validate.FieldError
if err := func() error {
if s.Error.Set {
if err := func() error {
if err := s.Error.Value.Validate(); err != nil {
return err return err
} }
return nil return nil
@ -251,22 +332,26 @@ func (s *ErrorResponsePayload) Validate() error {
return nil return nil
}(); err != nil { }(); err != nil {
failures = append(failures, validate.FieldError{ failures = append(failures, validate.FieldError{
Name: "error", Name: "publishedTimeText",
Error: err, Error: err,
}) })
} }
if len(failures) > 0 { if err := func() error {
return &validate.Error{Fields: failures} if err := s.ViewCountText.Validate(); err != nil {
return err
} }
return nil return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "viewCountText",
Error: err,
})
} }
func (s *ErrorResponsePayloadError) Validate() error {
var failures []validate.FieldError
if err := func() error { if err := func() error {
if s.Code.Set { if s.LengthText.Set {
if err := func() error { if err := func() error {
if err := (validate.Float{}).Validate(float64(s.Code.Value)); err != nil { if err := s.LengthText.Value.Validate(); err != nil {
return errors.Wrap(err, "float") return err
} }
return nil return nil
}(); err != nil { }(); err != nil {
@ -276,7 +361,43 @@ func (s *ErrorResponsePayloadError) Validate() error {
return nil return nil
}(); err != nil { }(); err != nil {
failures = append(failures, validate.FieldError{ failures = append(failures, validate.FieldError{
Name: "code", Name: "lengthText",
Error: err,
})
}
if err := func() error {
if s.ShortBylineText.Set {
if err := func() error {
if err := s.ShortBylineText.Value.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "shortBylineText",
Error: err,
})
}
if err := func() error {
if s.ShortViewCountText.Set {
if err := func() error {
if err := s.ShortViewCountText.Value.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "shortViewCountText",
Error: err, Error: err,
}) })
} }
@ -288,6 +409,9 @@ func (s *ErrorResponsePayloadError) Validate() error {
func (s *ItemSectionRenderer) Validate() error { func (s *ItemSectionRenderer) Validate() error {
var failures []validate.FieldError var failures []validate.FieldError
if err := func() error { if err := func() error {
if s.Contents == nil {
return errors.New("nil is invalid value")
}
var failures []validate.FieldError var failures []validate.FieldError
for i, elem := range s.Contents { for i, elem := range s.Contents {
if err := func() error { if err := func() error {
@ -319,6 +443,42 @@ func (s *ItemSectionRenderer) Validate() error {
} }
func (s *ItemSectionRendererContentsItem) Validate() error { func (s *ItemSectionRendererContentsItem) Validate() error {
var failures []validate.FieldError var failures []validate.FieldError
if err := func() error {
if s.CompactPlaylistRenderer.Set {
if err := func() error {
if err := s.CompactPlaylistRenderer.Value.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "compactPlaylistRenderer",
Error: err,
})
}
if err := func() error {
if s.CompactChannelRenderer.Set {
if err := func() error {
if err := s.CompactChannelRenderer.Value.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "compactChannelRenderer",
Error: err,
})
}
if err := func() error { if err := func() error {
if s.CompactVideoRenderer.Set { if s.CompactVideoRenderer.Set {
if err := func() error { if err := func() error {
@ -342,14 +502,72 @@ func (s *ItemSectionRendererContentsItem) Validate() error {
} }
return nil return nil
} }
func (s *KidsAppContentSettings) Validate() error {
func (s *ResponseContext) Validate() error {
var failures []validate.FieldError var failures []validate.FieldError
if err := func() error { if err := func() error {
if s.MaxAgeSeconds.Set { if err := s.CorpusPreference.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "corpusPreference",
Error: err,
})
}
if err := func() error { if err := func() error {
if err := (validate.Float{}).Validate(float64(s.MaxAgeSeconds.Value)); err != nil { if err := s.KidsNoSearchMode.Validate(); err != nil {
return errors.Wrap(err, "float") return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "kidsNoSearchMode",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s KidsAppContentSettingsCorpusPreference) Validate() error {
switch s {
case "KIDS_CORPUS_PREFERENCE_UNKNOWN":
return nil
case "KIDS_CORPUS_PREFERENCE_YOUNGER":
return nil
case "KIDS_CORPUS_PREFERENCE_TWEEN":
return nil
case "KIDS_CORPUS_PREFERENCE_PAM_YOUNGER":
return nil
case "KIDS_CORPUS_PREFERENCE_PAM_TWEEN":
return nil
case "KIDS_CORPUS_PREFERENCE_PRESCHOOL":
return nil
default:
return errors.Errorf("invalid value: %v", s)
}
}
func (s KidsAppContentSettingsKidsNoSearchMode) Validate() error {
switch s {
case "YT_KIDS_NO_SEARCH_MODE_UNKNOWN":
return nil
case "YT_KIDS_NO_SEARCH_MODE_ON":
return nil
case "YT_KIDS_NO_SEARCH_MODE_OFF":
return nil
default:
return errors.Errorf("invalid value: %v", s)
}
}
func (s *KidsAppInfo) Validate() error {
var failures []validate.FieldError
if err := func() error {
if s.ContentSettings.Set {
if err := func() error {
if err := s.ContentSettings.Value.Validate(); err != nil {
return err
} }
return nil return nil
}(); err != nil { }(); err != nil {
@ -359,7 +577,44 @@ func (s *ResponseContext) Validate() error {
return nil return nil
}(); err != nil { }(); err != nil {
failures = append(failures, validate.FieldError{ failures = append(failures, validate.FieldError{
Name: "maxAgeSeconds", Name: "contentSettings",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s *RequestClient) Validate() error {
var failures []validate.FieldError
if err := func() error {
if err := s.KidsAppInfo.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "kidsAppInfo",
Error: err,
})
}
if len(failures) > 0 {
return &validate.Error{Fields: failures}
}
return nil
}
func (s *RequestContext) Validate() error {
var failures []validate.FieldError
if err := func() error {
if err := s.Client.Validate(); err != nil {
return err
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "client",
Error: err, Error: err,
}) })
} }
@ -482,41 +737,16 @@ func (s *SectionListRendererContentsItem) Validate() error {
} }
return nil return nil
} }
func (s *Thumbnail) Validate() error { func (s *Text) Validate() error {
var failures []validate.FieldError var failures []validate.FieldError
if err := func() error { if err := func() error {
if s.Width.Set { if s.Runs == nil {
if err := func() error { return errors.New("nil is invalid value")
if err := (validate.Float{}).Validate(float64(s.Width.Value)); err != nil {
return errors.Wrap(err, "float")
}
return nil
}(); err != nil {
return err
}
} }
return nil return nil
}(); err != nil { }(); err != nil {
failures = append(failures, validate.FieldError{ failures = append(failures, validate.FieldError{
Name: "width", Name: "runs",
Error: err,
})
}
if err := func() error {
if s.Height.Set {
if err := func() error {
if err := (validate.Float{}).Validate(float64(s.Height.Value)); err != nil {
return errors.Wrap(err, "float")
}
return nil
}(); err != nil {
return err
}
}
return nil
}(); err != nil {
failures = append(failures, validate.FieldError{
Name: "height",
Error: err, Error: err,
}) })
} }