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

move api/v2/version endpoint to OPTIONS /api #8506

Merged
merged 5 commits into from May 24, 2019

Conversation

bartcharbon
Copy link
Member

@bartcharbon bartcharbon commented May 21, 2019

Checklist

  • Functionality works & meets specifications
  • Code reviewed
  • Code unit/integration/system tested
  • [n.a.] Migration step added in case of breaking change
  • [n.a.] User documentation updated
  • (If you have changed REST API interface) view-swagger.ftl updated
  • [n.a.] Test plan template updated
  • Clean commits
  • Added Feature/Fix to release notes

@codecov
Copy link

codecov bot commented May 21, 2019

Codecov Report

Merging #8506 into master will increase coverage by <.1%.
The diff coverage is 85.7%.

Impacted file tree graph

@@            Coverage Diff             @@
##             master   #8506     +/-   ##
==========================================
+ Coverage      62.4%   62.4%   +<.1%     
- Complexity     8122    8130      +8     
==========================================
  Files          1316    1319      +3     
  Lines         38638   38651     +13     
  Branches       3865    3865             
==========================================
+ Hits          24119   24131     +12     
- Misses        12829   12830      +1     
  Partials       1690    1690
Flag Coverage Δ Complexity Δ
#api 100% <ø> (ø) 0 <ø> (ø) ⬇️
#integration 7.6% <ø> (ø) 3 <ø> (ø) ⬇️
#unit 62.4% <85.7%> (ø) 8127 <6> (+8) ⬆️
Impacted Files Coverage Δ Complexity Δ
...ava/org/molgenis/api/data/v2/RestControllerV2.java 75.9% <ø> (ø) 71 <0> (ø) ⬇️
...rc/main/java/org/molgenis/api/OptionsResponse.java 100% <100%> (ø) 2 <2> (?)
...main/java/org/molgenis/api/AppVersionResponse.java 100% <100%> (ø) 2 <2> (?)
.../src/main/java/org/molgenis/api/ApiController.java 100% <100%> (ø) 7 <0> (+1) ⬆️
.../main/java/org/molgenis/api/RootApiController.java 77.7% <77.7%> (ø) 2 <2> (?)
...ain/java/org/molgenis/data/importer/ImportRun.java 86.6% <0%> (+2.2%) 23% <0%> (+1%) ⬆️

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 0c33a08...b7cf473. Read the comment docs.

@@ -55,6 +55,7 @@
import static org.testng.reporters.Files.readFile;

import com.google.common.collect.Sets;
import java.text.ParseException;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is suggest not to change any tests (see comment in RestControllerV2).

@@ -17,7 +17,7 @@
*/
public ApiController(String apiId, Integer apiVersion) {
requireNonNull(apiId);
if (!API_ID_PATTERN.matcher(apiId).matches()) {
if (!apiId.isEmpty() && !API_ID_PATTERN.matcher(apiId).matches()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a unit test for empty apiId

@@ -0,0 +1,8 @@
package org.molgenis.api;

public class VersionApiNamespace {
Copy link
Contributor

Choose a reason for hiding this comment

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

We agreed on OPTIONS /api to expose the application version, right? That would make this class unnecessary.


@RestController
@RequestMapping(API_PATH)
public class VersionController extends ApiController {
Copy link
Contributor

Choose a reason for hiding this comment

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

How about renaming this class to RootApiController so we can extend it with other planned endpoints such as listing all apis with their versions?


@Autowired
@RequestMapping(method = OPTIONS)
public VersionResponse getVersion() throws ParseException {
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest storing the version information under the app key.

{
  "app": {
    "version": "...",
    "buildDate": "..."
  },
  "apis": []
}

The apis key could be added in the future.

.andReturn();
String actual = result.getResponse().getContentAsString();
String expected =
"{\"molgenisVersion\":\"versionString\",\"buildDate\":\"2019-05-21T10:32:00Z\"}";
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that it is a good idea to use one format for date-times in JSON requests/responses everywhere. Did you look into adding milliseconds? It would make sense considering the places where we use datetimes.

Copy link
Member Author

Choose a reason for hiding this comment

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

Response object contains an Instant, the conversion to json is than done centrally by the application right?

@AutoGson(autoValueClass = AutoValue_VersionResponse.class)
@SuppressWarnings("squid:S1610")
public abstract class VersionResponse {
public abstract String getMolgenisVersion();
Copy link
Contributor

Choose a reason for hiding this comment

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

getVersion instead of getMolgenisVersion

new VersionController("versionString", "2019-05-21 10:32 UTC");
mockMvc =
MockMvcBuilders.standaloneSetup(versionController)
.setMessageConverters(new FormHttpMessageConverter(), gsonHttpMessageConverter)
Copy link
Contributor

Choose a reason for hiding this comment

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

I suspect you don't need a FormHttpMessageConverter here.

@bartcharbon bartcharbon force-pushed the api/version branch 2 times, most recently from ce6268f to 681e992 Compare May 23, 2019 12:34
@TestExecutionListeners(listeners = WithSecurityContextTestExecutionListener.class)
@TestPropertySource(properties = {"molgenis.version = 10.3.8"})
@ContextConfiguration(classes = {GsonConfig.class})
public class VersionControllerTest extends AbstractTestNGSpringContextTests {
Copy link
Contributor

Choose a reason for hiding this comment

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

Rename to RootApiControllerTest


@RestController
@RequestMapping(API_PATH)
public class RootApiController extends ApiController {
Copy link
Contributor

Choose a reason for hiding this comment

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

Add swagger annotations

Copy link
Contributor

Choose a reason for hiding this comment

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

swagger not working yet

@AutoValue
@AutoGson(autoValueClass = AutoValue_VersionResponse.class)
@SuppressWarnings("squid:S1610")
public abstract class VersionResponse {
Copy link
Contributor

Choose a reason for hiding this comment

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

Rename to something like OptionsResponse/ApiOptionsResponse


@Autowired
@RequestMapping(method = OPTIONS)
public VersionResponse getVersion() throws ParseException {
Copy link
Contributor

Choose a reason for hiding this comment

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

Deprecate /api/v2 version endpoint and refer to this endpoint

@dennishendriksen dennishendriksen merged commit 5138856 into molgenis:master May 24, 2019
@bartcharbon bartcharbon deleted the api/version branch August 27, 2019 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants