You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, my hands thank the Maintainers for handling this boilerplate! Second, I ran ogen on the Pinterest spec and it generated 116 client methods as expected. However, 93 of them return a *Res interface, while 23 of them return a pointer *...OK struct. Moreover, one of the methods returning an (unexpected) pointer *...OK struct works correctly, while another method returning an (expected) ...Res interface fails with:
./main.go:33:34: res.GetItems undefined (type api.CampaignsListRes has no field or method GetItems)
The very first call to client.AdAccountsList(ctx, api.AdAccountsListParams{}) works correctly, along with the following for ranging over res.GetItems(). However, the call to client.CampaignsList(ctx, params) returns the expectedCampaignsListRes interface, but then the second for fails because there's no GetItems() method on CampaignsListRes.
The documentation on Interface responses only has the ...Res interface, so why does client.AdAccountsList(ctx, api.AdAccountsListParams{}) return *AdAccountsListOK?
Finally, below is the relevant yaml from the Pinterest spec, but I had to fix 5 schema errors (2 excess indentations on minItems; 2 incorrect instances of string type that should be object type; and 1 incorrect usage of maxLength which should be maxItems).
paths:
/ad_accounts:
get:
summary: List ad accounts
description: |-
Get a list of the ad_accounts that the "operation user_account" has access to.
- This includes ad_accounts they own and ad_accounts that are owned by others who have granted them <a href="https://help.pinterest.com/en/business/article/share-and-manage-access-to-your-ad-accounts">Business Access</a>.
tags:
- ad_accounts
operationId: ad_accounts/list
security:
- pinterest_oauth2:
- ads:read
x-ratelimit-category: ads_read
x-sandbox: enabled
parameters:
- $ref: '#/components/parameters/query_bookmark'
- $ref: '#/components/parameters/query_page_size'
- $ref: '#/components/parameters/query_include_shared_accounts'
responses:
'200':
description: response
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/Paginated'
- type: object
properties:
items:
description: Ad accounts
items:
$ref: '#/components/schemas/AdAccount'
default:
description: Unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
...
/ad_accounts/{ad_account_id}/campaigns:
get:
summary: List campaigns
description: |-
Get a list of the campaigns in the specified <code>ad_account_id</code>, filtered by the specified options.
- The token's user_account must either be the Owner of the specified ad account, or have one of the necessary roles granted to them via <a href="https://help.pinterest.com/en/business/article/share-and-manage-access-to-your-ad-accounts">Business Access</a>: Admin, Analyst, Campaign Manager.
operationId: campaigns/list
security:
- pinterest_oauth2:
- ads:read
x-ratelimit-category: ads_read
x-sandbox: enabled
parameters:
- $ref: '#/components/parameters/path_ad_account_id'
- $ref: '#/components/parameters/query_campaign_ids'
- $ref: '#/components/parameters/query_entity_statuses'
- $ref: '#/components/parameters/query_page_size'
- $ref: '#/components/parameters/query_order'
- $ref: '#/components/parameters/query_bookmark'
responses:
'200':
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/Paginated'
- type: object
properties:
items:
type: array
items:
$ref: '#/components/schemas/CampaignResponse'
description: Success
'400':
description: Invalid ad account campaign parameters.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
code: 400
message: Invalid ad account campaign parameters.
default:
description: Unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
tags:
- campaigns
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
First, my hands thank the Maintainers for handling this boilerplate! Second, I ran
ogen
on the Pinterest spec and it generated 116 client methods as expected. However, 93 of them return a*Res interface
, while 23 of them return a pointer*...OK struct
. Moreover, one of the methods returning an (unexpected) pointer*...OK struct
works correctly, while another method returning an (expected)...Res interface
fails with:Here's my code:
The very first call to
client.AdAccountsList(ctx, api.AdAccountsListParams{})
works correctly, along with the followingfor
ranging overres.GetItems()
. However, the call toclient.CampaignsList(ctx, params)
returns the expectedCampaignsListRes interface
, but then the secondfor
fails because there's noGetItems()
method onCampaignsListRes
.The documentation on Interface responses only has the
...Res interface
, so why doesclient.AdAccountsList(ctx, api.AdAccountsListParams{})
return*AdAccountsListOK
?Here's the generated methods:
Here's my
ogen.yml
:Finally, below is the relevant yaml from the Pinterest spec, but I had to fix 5 schema errors (2 excess indentations on
minItems
; 2 incorrect instances ofstring
type that should beobject
type; and 1 incorrect usage ofmaxLength
which should bemaxItems
).Any help is appreciated! 🙏
Beta Was this translation helpful? Give feedback.
All reactions