Skip to content

Commit b8655b3

Browse files
authored
feat: add local-open-generator-cli (#37)
1 parent 2f30552 commit b8655b3

13 files changed

+53
-24
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Pinterest's REST API
66
This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
77

88
- API version: 5.14.0
9-
- Package version: 0.1.9
9+
- Package version: 0.1.10
1010
- Build package: org.openapitools.codegen.languages.PythonClientCodegen
1111
For more information, please visit [https://developers.pinterest.com/](https://developers.pinterest.com/)
1212

integration_test/base.py

+6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
from openapi_generated.pinterest_client.model.campaign_create_request import CampaignCreateRequest
1212
from openapi_generated.pinterest_client.model.objective_type import ObjectiveType
1313
from openapi_generated.pinterest_client.model.pin_create import PinCreate
14+
from openapi_generated.pinterest_client.model.targeting_spec import TargetingSpec
15+
1416
from .config import DEFAULT_AD_ACCOUNT_ID
1517
from .config import DEFAULT_AD_ACCOUNT_COUNTRY
1618
from .config import DEFAULT_AD_ACCOUNT_NAME
@@ -116,6 +118,10 @@ def ad_group(self):
116118
billable_event=action_type,
117119
tracking_url=None,
118120
bid_in_micro_currency=5000000,
121+
targeting_spec=TargetingSpec(
122+
age_bucket=["35-44"],
123+
location=[DEFAULT_AD_ACCOUNT_COUNTRY],
124+
)
119125
)],
120126
)
121127
self._ad_group = parse_to_object(response)

openapi_generated/pinterest_client/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"""
1212

1313

14-
__version__ = "0.1.9"
14+
__version__ = "0.1.10"
1515

1616
# import ApiClient
1717
from openapi_generated.pinterest_client.api_client import ApiClient

openapi_generated/pinterest_client/configuration.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ def to_debug_report(self):
426426
"OS: {env}\n"\
427427
"Python Version: {pyversion}\n"\
428428
"Version of the API: 5.14.0\n"\
429-
"SDK Package Version: 0.1.9".\
429+
"SDK Package Version: 0.1.10".\
430430
format(env=sys.platform, pyversion=sys.version)
431431

432432
def get_host_settings(self):

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
python_dateutil >= 2.5.3
22
setuptools >= 21.0.0
3-
urllib3 == 1.26.12
3+
urllib3 == 1.26.20

setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
import os
1717

18-
VERSION = "0.1.9"
18+
VERSION = "0.1.10"
1919
_IS_TEST_BUILD = os.environ.get("IS_TEST_BUILD", 0)
2020

2121
if _IS_TEST_BUILD:
@@ -31,7 +31,7 @@
3131
# http://pypi.python.org/pypi/setuptools
3232

3333
REQUIRES = [
34-
"urllib3==1.26.12",
34+
"urllib3==1.26.20",
3535
"python-dateutil",
3636
]
3737

spec/Makefile

+8-15
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
11
SHELL:=bash
22
OPENAPI_GENERATOR_VERSION:=5.4.0
3-
OPENAPI_GENERATOR_COMMAND:=openapi-generator-cli
4-
5-
ifeq (, $(shell which $(OPENAPI_GENERATOR_COMMAND)))
6-
OPENAPI_GENERATOR_COMMAND = openapi-generator
7-
endif
8-
9-
ifeq (, $(shell which $(OPENAPI_GENERATOR_COMMAND)))
10-
$(error Error: Command '$(OPENAPI_GENERATOR_COMMAND)' not found, make sure 'openapi-generator' is installed globablly)
11-
endif
12-
13-
ifneq ($(shell OPENAPI_GENERATOR_VERSION=$(OPENAPI_GENERATOR_VERSION) $(OPENAPI_GENERATOR_COMMAND) version), $(OPENAPI_GENERATOR_VERSION))
14-
$(error Error: Expected $(OPENAPI_GENERATOR_COMMAND) version $(OPENAPI_GENERATOR_VERSION) (found $(shell $(OPENAPI_GENERATOR_COMMAND) version)))
15-
endif
3+
OPENAPI_GENERATOR_COMMAND:=local-openapi-generator-cli
164

175
# Additional debugging output can be enabled by setting e.g. DEBUG_MODELS=1.
186
ifeq ($(DEBUG_MODELS),1)
@@ -30,12 +18,17 @@ download_spec: ## Download openapi.yaml from public pinterest github repo
3018

3119
validate_spec: ## Validates the openapi spec: sdk.yaml
3220
@echo ====Validates the openapi spec: sdk.yaml====
33-
openapi-generator validate -i openapi.yaml
21+
./local-open-generator-cli validate -i openapi.yaml
3422

3523
generate_client: ## Generates a python client
3624
@echo ====Generates a python client using the sdk.yaml spec====
37-
openapi-generator generate -c config.yml -o ..
25+
./local-open-generator-cli generate -c config.yml -o ..
3826
rm -rf ../test ../.gitlab-ci.yml ../.travis.yml ../git_push.sh
3927

28+
29+
generate_client: ## Patch the generated client
30+
@echo ====Execiting patches====
31+
python ./patches/remove_bool_none_type.py
32+
4033
help: ## Show list of targets and purposes.
4134
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'

spec/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ generatorStability: STABLE
33
generatorType: CLIENT
44
generatorLanguage: python
55
inputSpec: openapi.yaml
6-
packageVersion: 0.1.9
6+
packageVersion: 0.1.10
77
projectName: Pinterest_Generated_Client
88
templateDir: templates
99
packageName: openapi_generated.pinterest_client

spec/local-open-generator-cli

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
java -jar openapi-generator-cli.jar "$@"

spec/openapi-generator-cli.jar

24.1 MB
Binary file not shown.

spec/patches/remove_bool_none_type.py

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""
2+
This script removes the import line "from openapi_generated.pinterest_client.model.bool_none_type import BoolNoneType"
3+
from all Python files in the 'openapi_generated' directory and its subdirectories. This is to fix the error:
4+
"ModuleNotFoundError: No module named 'openapi_generated.pinterest_client.model.bool_none_type'"
5+
"""
6+
import os
7+
8+
directory = '../openapi_generated'
9+
line_to_remove = "from openapi_generated.pinterest_client.model.bool_none_type import BoolNoneType"
10+
11+
print("Starting the script to remove the specified import line from all Python files in the 'openapi_generated' directory...")
12+
13+
for root, dirs, files in os.walk(directory):
14+
for file in files:
15+
if file.endswith(".py"):
16+
file_path = os.path.join(root, file)
17+
18+
with open(file_path, 'r', encoding='utf-8') as f:
19+
lines = f.readlines()
20+
21+
with open(file_path, 'w', encoding='utf-8') as f:
22+
for line in lines:
23+
if line.strip() != line_to_remove:
24+
f.write(line)
25+
else:
26+
print(f"Removed line from: {file_path}")
27+
28+
print("Script completed. The specified import line has been removed from all Python files in the 'openapi_generated' directory.")

spec/templates/requirements.mustache

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
python_dateutil >= 2.5.3
22
setuptools >= 21.0.0
3-
urllib3 == 1.26.12
3+
urllib3 == 1.26.20

spec/templates/setup.mustache

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ NAME = "{{{projectName}}}"
2525
# http://pypi.python.org/pypi/setuptools
2626

2727
REQUIRES = [
28-
"urllib3==1.26.12",
28+
"urllib3==1.26.20",
2929
"python-dateutil",
3030
{{#asyncio}}
3131
"aiohttp >= 3.0.0",

0 commit comments

Comments
 (0)