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

[3670] API Generation #285

Merged
merged 33 commits into from May 19, 2022
Merged

[3670] API Generation #285

merged 33 commits into from May 19, 2022

Conversation

ghost
Copy link

@ghost ghost commented Mar 8, 2022

VIVO GitHub issue:
vivo-project/VIVO#3670
vivo-project/VIVO#3677

What does this pull request do?

Create endpoints to generate OpenAPI specifications for an entire REST version, specific REST resource, all custom actions, or specific custom action as either application/yaml or application/json.

All REST yaml
https://editor.swagger.io/?url=https://gist.githubusercontent.com/wwelling/98775eeb6cac7c98fa90b24316d30711/raw/8a46f2e11d0f246957212f3b2e9cf079340ee1bb/vivo-generated-rest-api.yaml

All RPC yaml
https://editor.swagger.io/?url=https://gist.githubusercontent.com/wwelling/4109bfcc8d9cc6f10fcdcd983cc055d4/raw/509ea688227787e4513d36defc1b1e0db3a77ad9/vivo-generated-rpc-api.yaml

Single REST resource json
https://editor.swagger.io/?url=https://gist.githubusercontent.com/wwelling/76b5b2b7abb9d53137afbf684bcb803b/raw/997a393374f143f5711bdb62c131ce947d5cc830/test_person_resource.json

Single RPC action json
https://editor.swagger.io/?url=https://gist.githubusercontent.com/wwelling/b762b8ba097eb5fe96034c302a4e0c56/raw/39aad70e3353944e2e5d39e6f69c574dfd86d8f2/test_action.json

What it is not doing

  • Does not define the server object. https://swagger.io/specification/#server-object
  • Does not include validations for parameters.
  • Does not define error responses completely.
  • Does not define any headers.
  • Some missing descriptions as not available in RDF representation.
  • Does not provide examples.

Interested parties

Tag (@ mention) interested parties or, if unsure, @VIVO-project/vivo-committers

@ghost ghost changed the title api generation wip [3670] API Generation wip Mar 8, 2022
William Welling and others added 21 commits March 8, 2022 14:28
Work in Progress, add mimeType/contentType processing.
Update RPC OpenAPI generation
The OpenAPIv3 requires the "info" with "title" and "version".
This provides a temporary hardcoded values for these and I plan on having a discussion on what to do in this regard.

Utilize the Mockito ArgumentMatcher API to write a custom test for ensuring that the generated JSON and YAML OpenAPI Specs match pre-defined expecations.

The REST is stubbed out but not implemented within the scope of this commit.
It just occurred to me that this seems silly.
We are testing against the OpenAPI class and so the source data to compare against only needs to be in a single type.
I chose json over yaml.

Change the behavior of the program to just use a single test file for each expected response.
This got lost somewhere along the way.
Add it back.
There are some significant problems that are exposed and need to be investigated.
These are causing different kinds of failures (test failures and non-test failures that result in bad API).
@ghost ghost changed the title [3670] API Generation wip [3670] API Generation Mar 11, 2022
@ghost ghost marked this pull request as ready for review March 11, 2022 05:31
Alternate variation on getting the version.
Copy link
Contributor

@chenejac chenejac left a comment

Choose a reason for hiding this comment

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

@wwelling and @kaladay well done. I have added a couple of comments, please read it and check whether some of them are useful for some minor improvements before we merge this contribution.

Operation operation = new Operation();
operation.addTagsItem(tag.getName());

// No description available per resource API rpc
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it doesn't not exist in examples, but I believe it is allowed to be added in accordance with the ontology: https://github.com/vivo-project/Vitro/blob/sprint-dynapi-2022-feb-staging/home/src/main/resources/rdf/tbox/filegraph/vitro-dynamic-api.owl#L441

Copy link
Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, it should be added to https://github.com/vivo-project/Vitro/blob/sprint-dynapi-2022-feb-staging/api/src/main/java/edu/cornell/mannlib/vitro/webapp/dynapi/components/RPC.java, right? We need separated description for PUT, POST, GET and DELETE methods? Anyway, it is not there, and I will add it in the separated PR.

@ghost ghost requested a review from chenejac March 22, 2022 16:48
Copy link
Contributor

@litvinovg litvinovg left a comment

Choose a reason for hiding this comment

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

Looks and works good.

@litvinovg litvinovg merged commit beab59b into vivo-project:sprint-dynapi-2022-feb-staging May 19, 2022
litvinovg added a commit to litvinovg/Vitro that referenced this pull request Jun 30, 2023
* api generation wip

* More api generation wip

* Work in Progress, add mimeType/contentType processing.

* update rpc endpoint generation

* Implement Argument Matcher and test the OpenAPI documentation for RPC.

The OpenAPIv3 requires the "info" with "title" and "version".
This provides a temporary hardcoded values for these and I plan on having a discussion on what to do in this regard.

Utilize the Mockito ArgumentMatcher API to write a custom test for ensuring that the generated JSON and YAML OpenAPI Specs match pre-defined expecations.

The REST is stubbed out but not implemented within the scope of this commit.

* Only a single type of test data is needed.

It just occurred to me that this seems silly.
We are testing against the OpenAPI class and so the source data to compare against only needs to be in a single type.
I chose json over yaml.

Change the behavior of the program to just use a single test file for each expected response.

* Add comments to the requests() function for generating parameters.

This got lost somewhere along the way.
Add it back.

* Work In Progress.

There are some significant problems that are exposed and need to be investigated.
These are causing different kinds of failures (test failures and non-test failures that result in bad API).

* revert change to versioned pool and correct expected data

* update tag name with key and expected results

* fix duplicate resource api

* update operation date

* cleanup testing n3

* update test expected results

* assert version 4 test api

* generate custom rest action api

* refactor integration test classes

* return first step required params

* Alternate variation on getting the version.

* align resource id constant

* initialize dynamic api documentation

* minor comment updates

* downgrade swagger-core to attempt resolve jackson version conflicts

* fix: use /api prefix for api documentation

* fix: added onGetAll object property

* fix: test n3 data

Co-authored-by: Kevin Day <kday@library.tamu.edu>
Co-authored-by: Kevin Day <35114839+kaladay@users.noreply.github.com>
Co-authored-by: Georgy Litvinov <git@litvinovg.pro>
litvinovg added a commit to litvinovg/Vitro that referenced this pull request Jul 6, 2023
* api generation wip

* More api generation wip

* Work in Progress, add mimeType/contentType processing.

* update rpc endpoint generation

* Implement Argument Matcher and test the OpenAPI documentation for RPC.

The OpenAPIv3 requires the "info" with "title" and "version".
This provides a temporary hardcoded values for these and I plan on having a discussion on what to do in this regard.

Utilize the Mockito ArgumentMatcher API to write a custom test for ensuring that the generated JSON and YAML OpenAPI Specs match pre-defined expecations.

The REST is stubbed out but not implemented within the scope of this commit.

* Only a single type of test data is needed.

It just occurred to me that this seems silly.
We are testing against the OpenAPI class and so the source data to compare against only needs to be in a single type.
I chose json over yaml.

Change the behavior of the program to just use a single test file for each expected response.

* Add comments to the requests() function for generating parameters.

This got lost somewhere along the way.
Add it back.

* Work In Progress.

There are some significant problems that are exposed and need to be investigated.
These are causing different kinds of failures (test failures and non-test failures that result in bad API).

* revert change to versioned pool and correct expected data

* update tag name with key and expected results

* fix duplicate resource api

* update operation date

* cleanup testing n3

* update test expected results

* assert version 4 test api

* generate custom rest action api

* refactor integration test classes

* return first step required params

* Alternate variation on getting the version.

* align resource id constant

* initialize dynamic api documentation

* minor comment updates

* downgrade swagger-core to attempt resolve jackson version conflicts

* fix: use /api prefix for api documentation

* fix: added onGetAll object property

* fix: test n3 data

Co-authored-by: Kevin Day <kday@library.tamu.edu>
Co-authored-by: Kevin Day <35114839+kaladay@users.noreply.github.com>
Co-authored-by: Georgy Litvinov <git@litvinovg.pro>
litvinovg added a commit to litvinovg/Vitro that referenced this pull request Mar 7, 2024
* api generation wip

* More api generation wip

* Work in Progress, add mimeType/contentType processing.

* update rpc endpoint generation

* Implement Argument Matcher and test the OpenAPI documentation for RPC.

The OpenAPIv3 requires the "info" with "title" and "version".
This provides a temporary hardcoded values for these and I plan on having a discussion on what to do in this regard.

Utilize the Mockito ArgumentMatcher API to write a custom test for ensuring that the generated JSON and YAML OpenAPI Specs match pre-defined expecations.

The REST is stubbed out but not implemented within the scope of this commit.

* Only a single type of test data is needed.

It just occurred to me that this seems silly.
We are testing against the OpenAPI class and so the source data to compare against only needs to be in a single type.
I chose json over yaml.

Change the behavior of the program to just use a single test file for each expected response.

* Add comments to the requests() function for generating parameters.

This got lost somewhere along the way.
Add it back.

* Work In Progress.

There are some significant problems that are exposed and need to be investigated.
These are causing different kinds of failures (test failures and non-test failures that result in bad API).

* revert change to versioned pool and correct expected data

* update tag name with key and expected results

* fix duplicate resource api

* update operation date

* cleanup testing n3

* update test expected results

* assert version 4 test api

* generate custom rest action api

* refactor integration test classes

* return first step required params

* Alternate variation on getting the version.

* align resource id constant

* initialize dynamic api documentation

* minor comment updates

* downgrade swagger-core to attempt resolve jackson version conflicts

* fix: use /api prefix for api documentation

* fix: added onGetAll object property

* fix: test n3 data

Co-authored-by: Kevin Day <kday@library.tamu.edu>
Co-authored-by: Kevin Day <35114839+kaladay@users.noreply.github.com>
Co-authored-by: Georgy Litvinov <git@litvinovg.pro>
litvinovg added a commit to litvinovg/Vitro that referenced this pull request Mar 8, 2024
* api generation wip

* More api generation wip

* Work in Progress, add mimeType/contentType processing.

* update rpc endpoint generation

* Implement Argument Matcher and test the OpenAPI documentation for RPC.

The OpenAPIv3 requires the "info" with "title" and "version".
This provides a temporary hardcoded values for these and I plan on having a discussion on what to do in this regard.

Utilize the Mockito ArgumentMatcher API to write a custom test for ensuring that the generated JSON and YAML OpenAPI Specs match pre-defined expecations.

The REST is stubbed out but not implemented within the scope of this commit.

* Only a single type of test data is needed.

It just occurred to me that this seems silly.
We are testing against the OpenAPI class and so the source data to compare against only needs to be in a single type.
I chose json over yaml.

Change the behavior of the program to just use a single test file for each expected response.

* Add comments to the requests() function for generating parameters.

This got lost somewhere along the way.
Add it back.

* Work In Progress.

There are some significant problems that are exposed and need to be investigated.
These are causing different kinds of failures (test failures and non-test failures that result in bad API).

* revert change to versioned pool and correct expected data

* update tag name with key and expected results

* fix duplicate resource api

* update operation date

* cleanup testing n3

* update test expected results

* assert version 4 test api

* generate custom rest action api

* refactor integration test classes

* return first step required params

* Alternate variation on getting the version.

* align resource id constant

* initialize dynamic api documentation

* minor comment updates

* downgrade swagger-core to attempt resolve jackson version conflicts

* fix: use /api prefix for api documentation

* fix: added onGetAll object property

* fix: test n3 data

Co-authored-by: Kevin Day <kday@library.tamu.edu>
Co-authored-by: Kevin Day <35114839+kaladay@users.noreply.github.com>
Co-authored-by: Georgy Litvinov <git@litvinovg.pro>
litvinovg added a commit that referenced this pull request Apr 19, 2024
* api generation wip

* More api generation wip

* Work in Progress, add mimeType/contentType processing.

* update rpc endpoint generation

* Implement Argument Matcher and test the OpenAPI documentation for RPC.

The OpenAPIv3 requires the "info" with "title" and "version".
This provides a temporary hardcoded values for these and I plan on having a discussion on what to do in this regard.

Utilize the Mockito ArgumentMatcher API to write a custom test for ensuring that the generated JSON and YAML OpenAPI Specs match pre-defined expecations.

The REST is stubbed out but not implemented within the scope of this commit.

* Only a single type of test data is needed.

It just occurred to me that this seems silly.
We are testing against the OpenAPI class and so the source data to compare against only needs to be in a single type.
I chose json over yaml.

Change the behavior of the program to just use a single test file for each expected response.

* Add comments to the requests() function for generating parameters.

This got lost somewhere along the way.
Add it back.

* Work In Progress.

There are some significant problems that are exposed and need to be investigated.
These are causing different kinds of failures (test failures and non-test failures that result in bad API).

* revert change to versioned pool and correct expected data

* update tag name with key and expected results

* fix duplicate resource api

* update operation date

* cleanup testing n3

* update test expected results

* assert version 4 test api

* generate custom rest action api

* refactor integration test classes

* return first step required params

* Alternate variation on getting the version.

* align resource id constant

* initialize dynamic api documentation

* minor comment updates

* downgrade swagger-core to attempt resolve jackson version conflicts

* fix: use /api prefix for api documentation

* fix: added onGetAll object property

* fix: test n3 data

Co-authored-by: Kevin Day <kday@library.tamu.edu>
Co-authored-by: Kevin Day <35114839+kaladay@users.noreply.github.com>
Co-authored-by: Georgy Litvinov <git@litvinovg.pro>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants