Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix code-gen #45

Merged
merged 1 commit into from
Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions convert.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import json

with open('swagger.json', 'r') as file:
param = """{ "description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.", "in": "header", "name": "X-Request-Id", "type": "string" }"""
response = """"X-Request-Id": { "description": "This header identifies the call", "type": "string" }"""
data = file.read().replace("\n","")
data = data.replace(param, "")
data = data.replace(response, "")
print(data)

f = open("swagger.json", "w")
mydata = json.loads(data)
f.write(json.dumps(mydata, indent=4))
f.close()
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"pretest": "npm-run-all envconfig",
"test": "jest --coverage --ci --testResultsProcessor jest-sonar-reporter",
"test:local": "jest --coverage --ci",
"generate:api": "rm -f swagger.json && wget https://raw.githubusercontent.com/pagopa/pagopa-api-config/main/openapi/swagger.json && sed -i 's/\\\\/\\\\\\\\/g' swagger.json && gen-api-models --api-spec swagger.json --no-strict --out-dir generated/api --request-types --response-decoders --client",
"macosx:generate:api": "rm -f swagger.json && wget https://raw.githubusercontent.com/pagopa/pagopa-api-config/main/openapi/swagger.json && sed -i '' 's/\\\\/\\\\\\\\/g' swagger.json && gen-api-models --api-spec swagger.json --no-strict --out-dir generated/api --request-types --response-decoders --client",
"generate:api": "rm -f swagger.json && wget https://raw.githubusercontent.com/pagopa/pagopa-api-config/main/openapi/swagger.json && sed -i 's/\\\\/\\\\\\\\/g' swagger.json && python3 ./convert.py && gen-api-models --api-spec swagger.json --no-strict --out-dir generated/api --request-types --response-decoders --client",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is the better solution to deploy now ok.
But 2 things :

  • link issue in to PR desc
  • we'd create a task in a story debito tecnico to put there . As place for all things to see asap

"macosx:generate:api": "rm -f swagger.json && wget https://raw.githubusercontent.com/pagopa/pagopa-api-config/main/openapi/swagger.json && sed -i '' 's/\\\\/\\\\\\\\/g' swagger.json && python3 ./convert.py && gen-api-models --api-spec swagger.json --no-strict --out-dir generated/api --request-types --response-decoders --client",
"generate": "npm-run-all generate:*",
"prettify": "prettier --write \"./**/*.{ts,tsx}\""
},
Expand Down
4 changes: 2 additions & 2 deletions src/pages/brokers/BrokersPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export default class BrokersPage extends React.Component<IProps, IState> {
}
}

deleteBroker(access_token: string, broker_code: string) {
deleteBrokerCall(access_token: string, broker_code: string) {
apiClient.deleteBroker({
Authorization: `Bearer ${access_token}`,
ApiKey: "",
Expand Down Expand Up @@ -145,7 +145,7 @@ export default class BrokersPage extends React.Component<IProps, IState> {
})
.then((response: any) => {
if (this.state.brokerToDelete) {
this.deleteBroker(response.accessToken, this.state.brokerToDelete.broker_code);
this.deleteBrokerCall(response.accessToken, this.state.brokerToDelete.broker_code);
}
});

Expand Down
4 changes: 2 additions & 2 deletions src/pages/stations/Station.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class Station extends React.Component<IProps, IState> {
};
}

getStation(code: string): void {
getStationCall(code: string): void {
this.context.instance.acquireTokenSilent({
...loginRequest,
account: this.context.accounts[0]
Expand Down Expand Up @@ -63,7 +63,7 @@ export default class Station extends React.Component<IProps, IState> {
componentDidMount(): void {
const code: string = this.props.match.params.code as string;
this.setState({isError: false});
this.getStation(code);
this.getStationCall(code);
}

render(): React.ReactNode {
Expand Down