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

refactor: OpenAPI import #2373

Closed
wants to merge 13 commits into from
Closed

Conversation

bzp2010
Copy link
Contributor

@bzp2010 bzp2010 commented Mar 11, 2022

Please answer these questions before submitting a pull request, or your PR will get closed.

Why submit this pull request?

  • Bugfix
  • New feature provided
  • Improve performance
  • Backport patches

What changes will this PR take into?

Part of refactoring OpenAPI support to provide OpenAPI implementation based on the previous Loader interface and modifying the import handler to support handling of DataSets imports.

Checklist:

  • Did you explain what problem does this PR solve? Or what new features have been added?
  • Have you added corresponding test cases?
  • Have you modified the corresponding document?
  • Is this PR backward compatible? If it is not backward compatible, please discuss on the mailing list first

@codecov-commenter
Copy link

codecov-commenter commented Mar 11, 2022

Codecov Report

Merging #2373 (20b7949) into master (eb51353) will decrease coverage by 31.82%.
The diff coverage is 4.24%.

❗ Current head 20b7949 differs from pull request most recent head 3aa90ef. Consider uploading reports for the commit 3aa90ef to get more accurate results

Impacted file tree graph

@@             Coverage Diff             @@
##           master    #2373       +/-   ##
===========================================
- Coverage   62.04%   30.22%   -31.83%     
===========================================
  Files          57       59        +2     
  Lines        3905     3861       -44     
===========================================
- Hits         2423     1167     -1256     
- Misses       1197     2482     +1285     
+ Partials      285      212       -73     
Flag Coverage Δ
backend-e2e-test 30.22% <4.24%> (-6.78%) ⬇️
backend-unit-test ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...rnal/handler/data_loader/loader/openapi3/export.go 0.00% <0.00%> (ø)
...rnal/handler/data_loader/loader/openapi3/import.go 0.00% <0.00%> (ø)
api/internal/handler/data_loader/route_import.go 10.56% <7.25%> (-56.96%) ⬇️
api/internal/handler/schema/plugin.go 20.00% <0.00%> (-80.00%) ⬇️
api/internal/handler/label/label.go 10.34% <0.00%> (-74.14%) ⬇️
api/internal/handler/data_loader/route_export.go 3.76% <0.00%> (-71.24%) ⬇️
api/internal/handler/consumer/consumer.go 23.80% <0.00%> (-68.26%) ⬇️
api/internal/handler/schema/schema.go 28.00% <0.00%> (-64.00%) ⬇️
api/internal/utils/runtime/runtime.go 5.55% <0.00%> (-61.12%) ⬇️
api/internal/handler/tool/tool.go 40.00% <0.00%> (-60.00%) ⬇️
... and 22 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eb51353...3aa90ef. Read the comment docs.

@bzp2010 bzp2010 marked this pull request as ready for review March 12, 2022 07:48
Expect(result.Get("total").Uint()).To(Equal(uint64(1)))
Expect(result.Get("failed").Uint()).To(Equal(uint64(0)))
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Better to get the route to check after importing the openapi.

SetFormData(map[string]string{
"_file": "default.json",
"type": "openapi3",
"task_name": "test_petstore_expanded_yaml",
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing test for MergeRoute ?

@nic-chen
Copy link
Member

big PR...
will review later.

routeID := o.TaskName + "_" + strings.NewReplacer("/", "-", "{", "", "}", "").Replace(strings.TrimPrefix(uri, "/"))

// decide whether to merge multi method routes based on configuration
if o.MergeRoute {
Copy link
Member

Choose a reason for hiding this comment

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

We have a contributor who submitted a PR to merge routes with the same URI:
#2330

I think this feature should also be included after the refactoring:

if len(v.Servers) > 0 {
// create a new upstream when current path has separate Servers
upstreamID := routeID
upstream, path := generateUpstreamByServers(s.Servers, upstreamID)
Copy link
Member

Choose a reason for hiding this comment

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

s.Servers or v.Servers?

@bzp2010 bzp2010 closed this May 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants