Skip to content

Commit 8dcdbfd

Browse files
committed
Added a couple of new methods and correct usage of CSRF
1 parent 6702478 commit 8dcdbfd

16 files changed

+843
-30
lines changed

README.md

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,29 +61,66 @@ configuration = swagger_client.Configuration()
6161
configuration.api_key['LEETCODE_SESSION'] = 'YOUR_API_KEY'
6262
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
6363
# configuration.api_key_prefix['LEETCODE_SESSION'] = 'Bearer'
64+
# Configure API key authorization: headerCSRF
65+
configuration = swagger_client.Configuration()
66+
configuration.api_key['x-csrftoken'] = 'YOUR_API_KEY'
67+
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
68+
# configuration.api_key_prefix['x-csrftoken'] = 'Bearer'
6469

6570
# create an instance of the API class
6671
api_instance = swagger_client.DefaultApi(swagger_client.ApiClient(configuration))
72+
topic = 'topic_example' # str |
6773

6874
try:
69-
api_response = api_instance.problems_algorithms_get()
75+
api_response = api_instance.api_problems_topic_get(topic)
7076
pprint(api_response)
7177
except ApiException as e:
72-
print("Exception when calling DefaultApi->problems_algorithms_get: %s\n" % e)
78+
print("Exception when calling DefaultApi->api_problems_topic_get: %s\n" % e)
79+
80+
# Configure API key authorization: cookieCSRF
81+
configuration = swagger_client.Configuration()
82+
configuration.api_key['csrftoken'] = 'YOUR_API_KEY'
83+
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
84+
# configuration.api_key_prefix['csrftoken'] = 'Bearer'
85+
# Configure API key authorization: cookieSession
86+
configuration = swagger_client.Configuration()
87+
configuration.api_key['LEETCODE_SESSION'] = 'YOUR_API_KEY'
88+
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
89+
# configuration.api_key_prefix['LEETCODE_SESSION'] = 'Bearer'
90+
# Configure API key authorization: headerCSRF
91+
configuration = swagger_client.Configuration()
92+
configuration.api_key['x-csrftoken'] = 'YOUR_API_KEY'
93+
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
94+
# configuration.api_key_prefix['x-csrftoken'] = 'Bearer'
95+
96+
# create an instance of the API class
97+
api_instance = swagger_client.DefaultApi(swagger_client.ApiClient(configuration))
98+
referer = 'referer_example' # str |
99+
problem = 'problem_example' # str |
100+
body = swagger_client.Solution() # Solution | Solution to test (optional)
101+
102+
try:
103+
api_response = api_instance.problems_problem_interpret_solution_post(referer, problem, body=body)
104+
pprint(api_response)
105+
except ApiException as e:
106+
print("Exception when calling DefaultApi->problems_problem_interpret_solution_post: %s\n" % e)
73107
```
74108

75109
## Documentation for API Endpoints
76110

77-
All URIs are relative to *https://leetcode.com/api*
111+
All URIs are relative to *https://leetcode.com*
78112

79113
Class | Method | HTTP request | Description
80114
------------ | ------------- | ------------- | -------------
81-
*DefaultApi* | [**problems_algorithms_get**](docs/DefaultApi.md#problems_algorithms_get) | **GET** /problems/algorithms/ |
115+
*DefaultApi* | [**api_problems_topic_get**](docs/DefaultApi.md#api_problems_topic_get) | **GET** /api/problems/{topic}/ |
116+
*DefaultApi* | [**problems_problem_interpret_solution_post**](docs/DefaultApi.md#problems_problem_interpret_solution_post) | **POST** /problems/{problem}/interpret_solution/ |
82117

83118
## Documentation For Models
84119

85120
- [Difficulty](docs/Difficulty.md)
121+
- [Interpretation](docs/Interpretation.md)
86122
- [Problems](docs/Problems.md)
123+
- [Solution](docs/Solution.md)
87124
- [Stat](docs/Stat.md)
88125
- [StatStatusPair](docs/StatStatusPair.md)
89126

@@ -102,6 +139,12 @@ Class | Method | HTTP request | Description
102139
- **API key parameter name**: LEETCODE_SESSION
103140
- **Location**: URL query string
104141

142+
## headerCSRF
143+
144+
- **Type**: API key
145+
- **API key parameter name**: x-csrftoken
146+
- **Location**: HTTP header
147+
105148

106149
## Author
107150

docs/DefaultApi.md

Lines changed: 83 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# swagger_client.DefaultApi
22

3-
All URIs are relative to *https://leetcode.com/api*
3+
All URIs are relative to *https://leetcode.com*
44

55
Method | HTTP request | Description
66
------------- | ------------- | -------------
7-
[**problems_algorithms_get**](DefaultApi.md#problems_algorithms_get) | **GET** /problems/algorithms/ |
7+
[**api_problems_topic_get**](DefaultApi.md#api_problems_topic_get) | **GET** /api/problems/{topic}/ |
8+
[**problems_problem_interpret_solution_post**](DefaultApi.md#problems_problem_interpret_solution_post) | **POST** /problems/{problem}/interpret_solution/ |
89

9-
# **problems_algorithms_get**
10-
> Problems problems_algorithms_get()
10+
# **api_problems_topic_get**
11+
> Problems api_problems_topic_get(topic)
1112
1213

1314

@@ -29,27 +30,36 @@ configuration = swagger_client.Configuration()
2930
configuration.api_key['LEETCODE_SESSION'] = 'YOUR_API_KEY'
3031
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
3132
# configuration.api_key_prefix['LEETCODE_SESSION'] = 'Bearer'
33+
# Configure API key authorization: headerCSRF
34+
configuration = swagger_client.Configuration()
35+
configuration.api_key['x-csrftoken'] = 'YOUR_API_KEY'
36+
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
37+
# configuration.api_key_prefix['x-csrftoken'] = 'Bearer'
3238

3339
# create an instance of the API class
3440
api_instance = swagger_client.DefaultApi(swagger_client.ApiClient(configuration))
41+
topic = 'topic_example' # str |
3542

3643
try:
37-
api_response = api_instance.problems_algorithms_get()
44+
api_response = api_instance.api_problems_topic_get(topic)
3845
pprint(api_response)
3946
except ApiException as e:
40-
print("Exception when calling DefaultApi->problems_algorithms_get: %s\n" % e)
47+
print("Exception when calling DefaultApi->api_problems_topic_get: %s\n" % e)
4148
```
4249

4350
### Parameters
44-
This endpoint does not need any parameter.
51+
52+
Name | Type | Description | Notes
53+
------------- | ------------- | ------------- | -------------
54+
**topic** | [**str**](.md)| |
4555

4656
### Return type
4757

4858
[**Problems**](Problems.md)
4959

5060
### Authorization
5161

52-
[cookieCSRF](../README.md#cookieCSRF), [cookieSession](../README.md#cookieSession)
62+
[cookieCSRF](../README.md#cookieCSRF), [cookieSession](../README.md#cookieSession), [headerCSRF](../README.md#headerCSRF)
5363

5464
### HTTP request headers
5565

@@ -58,3 +68,68 @@ This endpoint does not need any parameter.
5868

5969
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
6070

71+
# **problems_problem_interpret_solution_post**
72+
> Interpretation problems_problem_interpret_solution_post(referer, problem, body=body)
73+
74+
75+
76+
### Example
77+
```python
78+
from __future__ import print_function
79+
import time
80+
import swagger_client
81+
from swagger_client.rest import ApiException
82+
from pprint import pprint
83+
84+
# Configure API key authorization: cookieCSRF
85+
configuration = swagger_client.Configuration()
86+
configuration.api_key['csrftoken'] = 'YOUR_API_KEY'
87+
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
88+
# configuration.api_key_prefix['csrftoken'] = 'Bearer'
89+
# Configure API key authorization: cookieSession
90+
configuration = swagger_client.Configuration()
91+
configuration.api_key['LEETCODE_SESSION'] = 'YOUR_API_KEY'
92+
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
93+
# configuration.api_key_prefix['LEETCODE_SESSION'] = 'Bearer'
94+
# Configure API key authorization: headerCSRF
95+
configuration = swagger_client.Configuration()
96+
configuration.api_key['x-csrftoken'] = 'YOUR_API_KEY'
97+
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
98+
# configuration.api_key_prefix['x-csrftoken'] = 'Bearer'
99+
100+
# create an instance of the API class
101+
api_instance = swagger_client.DefaultApi(swagger_client.ApiClient(configuration))
102+
referer = 'referer_example' # str |
103+
problem = 'problem_example' # str |
104+
body = swagger_client.Solution() # Solution | Solution to test (optional)
105+
106+
try:
107+
api_response = api_instance.problems_problem_interpret_solution_post(referer, problem, body=body)
108+
pprint(api_response)
109+
except ApiException as e:
110+
print("Exception when calling DefaultApi->problems_problem_interpret_solution_post: %s\n" % e)
111+
```
112+
113+
### Parameters
114+
115+
Name | Type | Description | Notes
116+
------------- | ------------- | ------------- | -------------
117+
**referer** | **str**| |
118+
**problem** | **str**| |
119+
**body** | [**Solution**](Solution.md)| Solution to test | [optional]
120+
121+
### Return type
122+
123+
[**Interpretation**](Interpretation.md)
124+
125+
### Authorization
126+
127+
[cookieCSRF](../README.md#cookieCSRF), [cookieSession](../README.md#cookieSession), [headerCSRF](../README.md#headerCSRF)
128+
129+
### HTTP request headers
130+
131+
- **Content-Type**: application/json
132+
- **Accept**: application/json
133+
134+
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
135+

docs/Interpretation.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Interpretation
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**interpret_id** | **str** | |
7+
**test_case** | **str** | |
8+
9+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
10+

docs/Solution.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Solution
2+
3+
## Properties
4+
Name | Type | Description | Notes
5+
------------ | ------------- | ------------- | -------------
6+
**data_input** | **str** | |
7+
**lang** | **str** | |
8+
**question_id** | **int** | |
9+
**test_mode** | **bool** | |
10+
**typed_code** | **str** | |
11+
12+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
13+

swagger.yml

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,38 @@ components:
1818
type: apiKey
1919
in: cookie
2020
name: csrftoken
21+
headerCSRF:
22+
type: apiKey
23+
in: header
24+
name: x-csrftoken
2125
schemas:
26+
Solution:
27+
required:
28+
- data_input
29+
- lang
30+
- question_id
31+
- test_mode
32+
- typed_code
33+
properties:
34+
data_input:
35+
type: string
36+
lang:
37+
type: string
38+
question_id:
39+
type: integer
40+
test_mode:
41+
type: boolean
42+
typed_code:
43+
type: string
44+
Interpretation:
45+
required:
46+
- interpret_id
47+
- test_case
48+
properties:
49+
interpret_id:
50+
type: string
51+
test_case:
52+
type: string
2253
Difficulty:
2354
required:
2455
- level
@@ -117,17 +148,52 @@ components:
117148
category_slug:
118149
type: string
119150
paths:
120-
/problems/algorithms/:
151+
/api/problems/{topic}/:
121152
get:
153+
parameters:
154+
- in: path
155+
name: topic
156+
required: true
157+
schema:
158+
enum: ['algorithms', 'database', 'shell', 'concurrency']
122159
responses:
123160
'200':
124-
description: Returns problems
161+
description: Returns problems by topic
125162
content:
126163
application/json:
127164
schema:
128165
$ref: '#/components/schemas/Problems'
166+
/problems/{problem}/interpret_solution/:
167+
post:
168+
parameters:
169+
- in: path
170+
name: problem
171+
required: true
172+
schema:
173+
type: string
174+
example: two-sum
175+
- in: header
176+
name: Referer
177+
schema:
178+
type: string
179+
required: true
180+
requestBody:
181+
description: Solution to test
182+
content:
183+
application/json:
184+
schema:
185+
$ref: '#/components/schemas/Solution'
186+
responses:
187+
'200':
188+
description: Returns problem test result
189+
content:
190+
application/json:
191+
schema:
192+
$ref: '#/components/schemas/Interpretation'
193+
129194
servers:
130-
- url: 'https://leetcode.com/api'
195+
- url: 'https://leetcode.com'
131196
security:
132197
- cookieSession: []
133198
cookieCSRF: []
199+
headerCSRF: []

swagger_client/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
from swagger_client.configuration import Configuration
2222
# import models into sdk package
2323
from swagger_client.models.difficulty import Difficulty
24+
from swagger_client.models.interpretation import Interpretation
2425
from swagger_client.models.problems import Problems
26+
from swagger_client.models.solution import Solution
2527
from swagger_client.models.stat import Stat
2628
from swagger_client.models.stat_status_pair import StatStatusPair

0 commit comments

Comments
 (0)