reddit: update open api spec
This commit is contained in:
parent
230138cecd
commit
4f2c0ec7b3
1
Makefile
1
Makefile
|
@ -16,6 +16,7 @@ run-web: generate-web
|
|||
|
||||
generate-go: migrate
|
||||
rm -rf go/gen/*
|
||||
ogen -target go/gen/reddit -package reddit -clean schemas/openapi/reddit.yaml
|
||||
(cd ./schemas/proto && buf generate --template buf.gen.go.yaml .)
|
||||
(cd go/gen && bobgen-sqlite --config ../bobgen.yaml)
|
||||
(cd go && goverter gen -g 'output:file ../gen/converter/converter.go' -g 'output:package github.com/tigorlazuardi/bluemage/go/gen/converter' ./converts)
|
||||
|
|
13
flake.nix
13
flake.nix
|
@ -31,6 +31,18 @@
|
|||
};
|
||||
vendorHash = "sha256-9vLcyCAhW/Dq0zV8FhM0T3Ofn/8XsUhV5KlphNidGDw=";
|
||||
};
|
||||
ogen = pkgs.buildGoModule rec {
|
||||
name = "ogen";
|
||||
version = "1.2.2";
|
||||
subPackages = [ "cmd/ogen" ];
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "ogen-go";
|
||||
repo = "ogen";
|
||||
rev = "v${version}";
|
||||
sha256 = "sha256-8HIbMw3G5vuOJMpwfrSiecm9+kmsHDkVqAG6xucoZfs=";
|
||||
};
|
||||
vendorHash = "sha256-sZiOo+ZhczWS7xMt2cxdqZM1C2omIYheZPLAJMLSw28=";
|
||||
};
|
||||
in
|
||||
{
|
||||
devShell.${system} = pkgs.mkShell {
|
||||
|
@ -50,6 +62,7 @@
|
|||
bobgen-sqlite
|
||||
air
|
||||
gopls
|
||||
ogen
|
||||
];
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
openapi: 3.0.3
|
||||
info:
|
||||
title: Reddit JSON Listing API
|
||||
description: JSON api listing for Subreddits and Users.
|
||||
description: |-
|
||||
JSON api listing for Subreddits and Users.
|
||||
|
||||
Request must have `User-Agent` header set to custom values and not empty.
|
||||
version: v1
|
||||
servers:
|
||||
- url: https://reddit.com
|
||||
|
@ -22,19 +25,19 @@ paths:
|
|||
this endpoint will redirect to `/subreddits/search.json?q={name}`
|
||||
with this kind of response body:
|
||||
|
||||
```json
|
||||
{
|
||||
"kind": "Listing",
|
||||
"data": {
|
||||
"after": null,
|
||||
"dist": 0,
|
||||
"modhash": "<hash>",
|
||||
"geo_filter": "",
|
||||
"children": [],
|
||||
"before": null
|
||||
}
|
||||
}
|
||||
```
|
||||
```json
|
||||
{
|
||||
"kind": "Listing",
|
||||
"data": {
|
||||
"after": null,
|
||||
"dist": 0,
|
||||
"modhash": "<hash>",
|
||||
"geo_filter": "",
|
||||
"children": [],
|
||||
"before": null
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Currently, Best way to check wether the subreddit exists or not
|
||||
is the `data.after` and `data.before` is null, and `data.children` array is empty.
|
||||
|
@ -111,7 +114,12 @@ paths:
|
|||
|
||||
Maximum value to fetch is `100`.
|
||||
example: 25
|
||||
operationId: getSubredditListing
|
||||
- in: header
|
||||
name: User-Agent
|
||||
schema:
|
||||
type: string
|
||||
default: bluemage/v1
|
||||
operationId: getListing
|
||||
responses:
|
||||
"200":
|
||||
description: success
|
||||
|
@ -119,6 +127,12 @@ paths:
|
|||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/ListingResponse"
|
||||
"429":
|
||||
description: Too many requests
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
|
||||
components:
|
||||
schemas:
|
||||
|
|
Loading…
Reference in a new issue