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
feat(nms): generate swagger api for typescript #12757
feat(nms): generate swagger api for typescript #12757
Conversation
Thanks for opening a PR! 💯
Howto
More infoPlease take a moment to read through the Magma project's
If this is your first Magma PR, also consider reading
|
cc6052e
to
f1ba4d5
Compare
ca72c95
to
c546c67
Compare
c546c67
to
5099783
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good.
sed -i -e 's/?view=full(/_view_full(/g' "${file}" | ||
sed -i -e 's/?verbose=false(/_verbose_false(/g' "${file}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this is the workaround for the hard-coded query parameters? Maybe add a TODO to remove them.
5099783
to
7934353
Compare
Changing the name of the type is not breaking API, right? |
Correct, that is only an internal thing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a lot of nitpicking on Bash, but please replace the find
in line 58 with something more specific.
orc8r/cloud/Makefile
Outdated
|
||
nms_gen: | ||
# generate Swagger API bindings for NMS | ||
$(MAGMA_ROOT)/nms/scripts/generateAPIFromSwagger.sh $(SWAGGER_V1_YML) $(SWAGGER_NMS_OUT) | ||
$(MAGMA_ROOT)/nms/scripts/generateAPIFromSwaggerForTypeScript.sh $(SWAGGER_V1_YML) $(SWAGGER_NMS_OUT_TS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be more idiomatic to call a gen
target in the nms
makefile. But since it was done that way also previously, it might be fine.
echo "Input file: $INPUT"; | ||
echo "Output directory: $OUTPUT"; | ||
|
||
yarn --silent openapi -i "${INPUT}" -o "${OUTPUT}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have to set --client axios
because we also used this API from node in a few places.
7934353
to
b602119
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
b602119
to
ada007d
Compare
ada007d
to
b49efa5
Compare
Signed-off-by: Fritz Lehnert <13189449+Neudrino@users.noreply.github.com>
Signed-off-by: Fritz Lehnert <13189449+Neudrino@users.noreply.github.com>
Signed-off-by: Fritz Lehnert <13189449+Neudrino@users.noreply.github.com>
…ackageType usage Signed-off-by: Thomas Schmitt <thomas.schmitt@tngtech.com>
b49efa5
to
dce6a29
Compare
A follow up is at #12761. |
* feat(nms): generate swagger api for typescript Signed-off-by: Fritz Lehnert <13189449+Neudrino@users.noreply.github.com> * feat(nms): rename package in swagger api Signed-off-by: Fritz Lehnert <13189449+Neudrino@users.noreply.github.com> * feat(nms): auto-generated files from swagger Signed-off-by: Fritz Lehnert <13189449+Neudrino@users.noreply.github.com> * refactor(nms): Make TypeScript generation script executable and fix PackageType usage Signed-off-by: Thomas Schmitt <thomas.schmitt@tngtech.com> Co-authored-by: Thomas Schmitt <thomas.schmitt@tngtech.com>
* feat(nms): generate swagger api for typescript Signed-off-by: Fritz Lehnert <13189449+Neudrino@users.noreply.github.com> * feat(nms): rename package in swagger api Signed-off-by: Fritz Lehnert <13189449+Neudrino@users.noreply.github.com> * feat(nms): auto-generated files from swagger Signed-off-by: Fritz Lehnert <13189449+Neudrino@users.noreply.github.com> * refactor(nms): Make TypeScript generation script executable and fix PackageType usage Signed-off-by: Thomas Schmitt <thomas.schmitt@tngtech.com> Co-authored-by: Thomas Schmitt <thomas.schmitt@tngtech.com>
Summary
Generate the Swagger API for TypeScript in parallel to the one for Flow.
This is a preparatory step for migrating the NMS to TypeScript.
The tool the we are using for the flow API generation is discontinued and generates a broken TypeScript API.
Therefore we had to use a different tool for TypeScript.
We found an issues in our current swagger spec that we had to work around. There are three endpoints that return a differently shaped response based on a query parameter. This has been realised by putting the URL a second time into the swagger spec with a hard coded query parameter, which is not allowed. We should probably fix that by splitting the endpoints at some point.
Another problem that we ran into is more related to the generation tool. It will create types with reserved keywords. Since this only effected a very sparingly used subtype we renamed the type to unblock us.
The TypeScript API will be added in a separate PR #12761.
Fixes #12756
Done in pairing with @thmsschmitt .