Skip to content

Commit 01b6fef

Browse files
committed
Simplify build for Python
1 parent d5d579c commit 01b6fef

File tree

3 files changed

+39
-5
lines changed

3 files changed

+39
-5
lines changed

Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM node:14
2+
RUN apt-get update && apt-get install -y default-jre \
3+
build-essential checkinstall libreadline-gplv2-dev \
4+
libncursesw5-dev libssl-dev libsqlite3-dev tk-dev \
5+
libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev \
6+
cd /opt && \
7+
wget https://www.python.org/ftp/python/3.8.7/Python-3.8.7.tgz && \
8+
tar xzf Python-3.8.7.tgz && \
9+
cd /opt/Python-3.8.7 && \
10+
./configure --enable-optimizations && \
11+
make altinstall && \
12+
rm -r /opt/Python-3.8.7 \
13+
rm /usr/bin/python && \
14+
ls -lah /usr/bin/python* && \
15+
ln -s $(which python3.8) /usr/bin/python
16+
# TODO: make golang works
17+
ENTRYPOINT ["/bin/bash", "-c"]
18+
WORKDIR /src
19+
CMD ["yarn start ts && yarn start python"]

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
IMAGE_NAME?=h1-generators
2+
IMAGE_TAG?=latest
3+
4+
.PHONY: build
5+
build:
6+
wget -O openapi.json https://api.hyperone.com/v2/openapi.json
7+
docker build -t ${IMAGE_NAME}:${IMAGE_TAG} .
8+
9+
.PHONY: start
10+
start:
11+
docker run -v $$HOME/.h1/passport.json:/root/.h1/passport.json -v $$PWD:/src --workdir /src ${IMAGE_NAME}:${IMAGE_TAG} "${EXEC}"

src/generators/python/index.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@ import { execute } from "../../utils/shellUtils";
55
import { copyLicense } from "../../utils/licenseUtils";
66
import { fixPathsInReplacedReadme } from "../../utils/fileUtils";
77

8-
const dropObjectPattern = (s: any) => {
8+
9+
const simplifyPattern = (value: string) => {
10+
if(value) value = value.replace(/\?\<.+?\>/, '')
11+
}
12+
const simplifyObjectPattern = (s: any) => {
913
if (!s.properties) return;
1014
for (const property of Object.values(s.properties)) {
1115
const p: any = property;
12-
delete p.pattern;
16+
p.pattern = simplifyPattern(p.pattern);
1317
if (p.items) {
14-
dropObjectPattern(p.items)
18+
simplifyObjectPattern(p.items)
1519
}
1620
}
1721
}
@@ -29,7 +33,7 @@ export const generatePythonClient = async (
2933
// example value: '.components.schemas.iam_project_policy_create.properties.resource'
3034
for (const schema of Object.values(specification.components.schemas)) {
3135
const s: any = schema;
32-
dropObjectPattern(s);
36+
simplifyObjectPattern(s);
3337
}
3438
// example value: .paths["/iam/project/{projectId}/policy"].get.parameters
3539
for (const endpoint of Object.values(specification.paths)) {
@@ -40,7 +44,7 @@ export const generatePythonClient = async (
4044
for (const parameter of o.parameters) {
4145
const p: any = parameter;
4246
if (!p.schema) continue;
43-
delete p.schema.pattern;
47+
p.schema.pattern = simplifyPattern(p.pattern);
4448
}
4549
}
4650
}

0 commit comments

Comments
 (0)