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

Update validation endpoint and remove authentication #8056

Merged
merged 10 commits into from
Jan 27, 2023

Conversation

arnejduranovic
Copy link
Collaborator

@arnejduranovic arnejduranovic commented Jan 24, 2023

This PR:

  1. Makes the validation endpoint(s) public. No authorization/authentication required.
  2. Splits the /validate endpoint into /validateWithClient and /validateWithSchema. /validateWithSchema is the new feature that allows a user to validate a message without having to know the client, which is hard to do if the endpoint requires no login.

Test Steps:

  1. To test the schema/format variation of the validation endpoint use the following curl command:
curl --location --request POST 'http://localhost:7071/api/validate?schema=hl7/hcintegrations-covid-19&format=HL7' \
--header 'Content-Type: application/hl7-v2' \
--header 'x-functions-key: dummy' \
--header 'Authorization: Bearer dummy' \
--data-raw 'MSH|^~\&|CDC PRIME - Atlanta, Georgia (Dekalb)^2.16.840.1.114222.4.1.237821^ISO|0.0.0.0.1^57D2109627^CLIA|0.0.0.0.1|0.0.0.0.1|20220816233337||ORU^R01^ORU_R01|186294|P|2.5.1|||NE|NE|USA|UNICODE UTF-8|ENG^English^ISO||PHLabReport-NoAck^dw1aq^e3yul7^if520yz2l
SFT|Centers for Disease Control and Prevention|0.2-SNAPSHOT|PRIME ReportStream|0.2-SNAPSHOT||20220816000000
PID|1||ifb09bywb^^^Any lab USA&57D2109627&CLIA^31axe^Any facility USA&57D2109627&CLIA||Stehr^Levi^Anibal^^^^q2alak4k||19991209||||193 Abshire Land^^Quincy^MI^49082^USA^^^26023||(227)772-3573^PRN^PH^^1^227^7723573~^NET^Internet^rae.funk@email.com||tut^Altaic (Other)^ISO|||||240-27-3470||N^Non Hispanic or Latino^HL70189^^^^2.9||||ARE^United Arab Emirates^ISO|||20220811|UNK
ORC|RE|090493^Any lab USA^49D5191021^CLIA|753721^Any lab USA^49D5191021^CLIA|477098^fwsnc0^17D0377921^CLIA||||||||1877078240^Koss^Catharine^Maxine^^^^^0.0.0.0.1^^^^qnxlf||(231)529-0544^WPN^PH^^1^231^5290544|20220811233336||||||Any facility USA^L|93025 Dare Coves^^Quincy^MI^49082^^^^26023|(241)255-1191^WPN^PH^^1^241^2551191|92303 Greenholt Shore^^Quincy^MI^49082^^^^26023
OBR|1|090493^Any lab USA^49D5191021^CLIA|753721^Any lab USA^49D5191021^CLIA|95209-3^SARS-CoV+SARS-CoV-2 (COVID-19) Ag [Presence] in Respiratory specimen by Rapid immunoassay^8ocu2^^^^2.68|||20220811233336|20220811233336||||||||1877078240^Koss^Catharine^Maxine^^^^^0.0.0.0.1^^^^qnxlf|(231)529-0544^WPN^PH^^1^231^5290544|||||20220811233336|||C||||||7sbj8fx
OBX|1|CWE|95209-3^SARS-CoV+SARS-CoV-2 (COVID-19) Ag [Presence] in Respiratory specimen by Rapid immunoassay^ak938^^^^2.68|567701|260415000^Not detected^SCT|z2gnhf|Negative|IND^Indeterminate^HL70078^^^^2.7|||F|||20220811233336|49D5191021^Any lab USA^CLIA||^LumiraDx SARS-CoV-2 Ag Test^99ELR^^^^2.68|LumiraDx Platform_LumiraDx^^MNI|20220811233336||||Any lab USA^^^^^0.0.0.0.1&9kyo7w&u5i1a63^XX^^^49D5191021|156 Slyvia Key^^Quincy^MI^49082^^^^26023
NTE|1|P|urugp5s4|RE^Remark^HL70364^^^^2.5.1
NTE|2||g3boju9|RE^Remark^HL70364^^^^2.5.1
OBX|2|CWE|82810-3^Pregnancy status^LN^^^^2.68||60001007^Not Pregnant^SCT||||||F|||20220811233336|49D5191021||||20220811233336||||Any lab USA^^^^^^XX^^^49D5191021|156 Slyvia Key^^Quincy^MI^49082^^^^Branch|||||QST
OBX|3|CWE|95418-0^Whether patient is employed in a healthcare setting^LN^^^^2.69||Y^Yes^HL70136||||||F|||20220811233336|49D5191021||||20220811233336||||Any lab USA^^^^^^XX^^^49D5191021|156 Slyvia Key^^Quincy^MI^49082^^^^Branch|||||QST
OBX|4|CWE|95417-2^First test for condition of interest^LN^^^^2.69||UNK^Unknown^NULLFL||||||F|||20220811233336|49D5191021||||20220811233336||||Any lab USA^^^^^^XX^^^49D5191021|156 Slyvia Key^^Quincy^MI^49082^^^^Branch|||||QST
OBX|5|CWE|77974-4^Patient was hospitalized because of this condition^LN||N^No^HL70136||||||F|||20220811233336|49D5191021||||20220811233336||||Any lab USA^^^^^^XX^^^49D5191021|156 Slyvia Key^^Quincy^MI^49082^^^^Branch|||||QST
OBX|6|CWE|95420-6^Admitted to intensive care unit for condition of interest^LN^^^^2.69||N^No^HL70136||||||F|||20220811233336|49D5191021||||20220811233336||||Any lab USA^^^^^^XX^^^49D5191021|156 Slyvia Key^^Quincy^MI^49082^^^^Branch|||||QST
OBX|7|DT|65222-2^Date and time of symptom onset^LN^^^^2.68||20220811||||||F|||20220811233336|49D5191021||||20220811233336||||Any lab USA^^^^^^XX^^^49D5191021|156 Slyvia Key^^Quincy^MI^49082^^^^Branch|||||QST
OBX|8|NM|30525-0^Age^LN^^^^2.68||7||||||F|||20220811233336|49D5191021||||20220811233336||||Any lab USA^^^^^^XX^^^49D5191021|156 Slyvia Key^^Quincy^MI^49082^^^^Branch|||||QST
OBX|9|CWE|95421-4^Resides in a congregate care setting^LN^^^^2.69||UNK^Unknown^NULLFL||||||F|||20220811233336|49D5191021||||20220811233336||||Any lab USA^^^^^^XX^^^49D5191021|156 Slyvia Key^^Quincy^MI^49082^^^^Branch|||||QST
OBX|10|CWE|95419-8^Has symptoms related to condition of interest^LN^^^^2.69||UNK^Unknown^NULLFL||||||F|||20220811233336|49D5191021||||20220811233336||||Any lab USA^^^^^^XX^^^49D5191021|156 Slyvia Key^^Quincy^MI^49082^^^^Branch|||||QST
OBX|11|CWE|75617-1^Residence type^LN^^^^2.68||285113009^Religious Institutional Residence^SCT||||||F|||20220811233336|49D5191021||||20220811233336||||Any lab USA^^^^^^XX^^^49D5191021|156 Slyvia Key^^Quincy^MI^49082^^^^Branch|||||QST
SPM|1|947347&Any facility USA&57D2109627&CLIA^753721&Any facility USA&57D2109627&CLIA||445297001^Swab of internal nose^SCT^^^^2.67|||MARTL^Martin-Lewis Agar^HL70048|71836000^Nasopharyngeal structure (body structure)^SCT^^^^2020-09-01||h6xhitmyx|G|||d4uipoq6|||20220811233336|20220811233336
'
  1. To test the client variation of the validation endpoint use the following curl command.
curl --location --request POST 'http://localhost:7071/api/validate' \
--header 'Content-Type: application/hl7-v2' \
--header 'client: hcintegrations.default' \
--header 'x-functions-key: dummy' \
--header 'Authorization: Bearer dummy' \
--data-raw 'MSH|^~\&|CDC PRIME - Atlanta, Georgia (Dekalb)^2.16.840.1.114222.4.1.237821^ISO|0.0.0.0.1^57D2109627^CLIA|0.0.0.0.1|0.0.0.0.1|20220816233337||ORU^R01^ORU_R01|186294|P|2.5.1|||NE|NE|USA|UNICODE UTF-8|ENG^English^ISO||PHLabReport-NoAck^dw1aq^e3yul7^if520yz2l
SFT|Centers for Disease Control and Prevention|0.2-SNAPSHOT|PRIME ReportStream|0.2-SNAPSHOT||20220816000000
PID|1||ifb09bywb^^^Any lab USA&57D2109627&CLIA^31axe^Any facility USA&57D2109627&CLIA||Stehr^Levi^Anibal^^^^q2alak4k||19991209||||193 Abshire Land^^Quincy^MI^49082^USA^^^26023||(227)772-3573^PRN^PH^^1^227^7723573~^NET^Internet^rae.funk@email.com||tut^Altaic (Other)^ISO|||||240-27-3470||N^Non Hispanic or Latino^HL70189^^^^2.9||||ARE^United Arab Emirates^ISO|||20220811|UNK
ORC|RE|090493^Any lab USA^49D5191021^CLIA|753721^Any lab USA^49D5191021^CLIA|477098^fwsnc0^17D0377921^CLIA||||||||1877078240^Koss^Catharine^Maxine^^^^^0.0.0.0.1^^^^qnxlf||(231)529-0544^WPN^PH^^1^231^5290544|20220811233336||||||Any facility USA^L|93025 Dare Coves^^Quincy^MI^49082^^^^26023|(241)255-1191^WPN^PH^^1^241^2551191|92303 Greenholt Shore^^Quincy^MI^49082^^^^26023
OBR|1|090493^Any lab USA^49D5191021^CLIA|753721^Any lab USA^49D5191021^CLIA|95209-3^SARS-CoV+SARS-CoV-2 (COVID-19) Ag [Presence] in Respiratory specimen by Rapid immunoassay^8ocu2^^^^2.68|||20220811233336|20220811233336||||||||1877078240^Koss^Catharine^Maxine^^^^^0.0.0.0.1^^^^qnxlf|(231)529-0544^WPN^PH^^1^231^5290544|||||20220811233336|||C||||||7sbj8fx
OBX|1|CWE|95209-3^SARS-CoV+SARS-CoV-2 (COVID-19) Ag [Presence] in Respiratory specimen by Rapid immunoassay^ak938^^^^2.68|567701|260415000^Not detected^SCT|z2gnhf|Negative|IND^Indeterminate^HL70078^^^^2.7|||F|||20220811233336|49D5191021^Any lab USA^CLIA||^LumiraDx SARS-CoV-2 Ag Test^99ELR^^^^2.68|LumiraDx Platform_LumiraDx^^MNI|20220811233336||||Any lab USA^^^^^0.0.0.0.1&9kyo7w&u5i1a63^XX^^^49D5191021|156 Slyvia Key^^Quincy^MI^49082^^^^26023
NTE|1|P|urugp5s4|RE^Remark^HL70364^^^^2.5.1
NTE|2||g3boju9|RE^Remark^HL70364^^^^2.5.1
OBX|2|CWE|82810-3^Pregnancy status^LN^^^^2.68||60001007^Not Pregnant^SCT||||||F|||20220811233336|49D5191021||||20220811233336||||Any lab USA^^^^^^XX^^^49D5191021|156 Slyvia Key^^Quincy^MI^49082^^^^Branch|||||QST
OBX|3|CWE|95418-0^Whether patient is employed in a healthcare setting^LN^^^^2.69||Y^Yes^HL70136||||||F|||20220811233336|49D5191021||||20220811233336||||Any lab USA^^^^^^XX^^^49D5191021|156 Slyvia Key^^Quincy^MI^49082^^^^Branch|||||QST
OBX|4|CWE|95417-2^First test for condition of interest^LN^^^^2.69||UNK^Unknown^NULLFL||||||F|||20220811233336|49D5191021||||20220811233336||||Any lab USA^^^^^^XX^^^49D5191021|156 Slyvia Key^^Quincy^MI^49082^^^^Branch|||||QST
OBX|5|CWE|77974-4^Patient was hospitalized because of this condition^LN||N^No^HL70136||||||F|||20220811233336|49D5191021||||20220811233336||||Any lab USA^^^^^^XX^^^49D5191021|156 Slyvia Key^^Quincy^MI^49082^^^^Branch|||||QST
OBX|6|CWE|95420-6^Admitted to intensive care unit for condition of interest^LN^^^^2.69||N^No^HL70136||||||F|||20220811233336|49D5191021||||20220811233336||||Any lab USA^^^^^^XX^^^49D5191021|156 Slyvia Key^^Quincy^MI^49082^^^^Branch|||||QST
OBX|7|DT|65222-2^Date and time of symptom onset^LN^^^^2.68||20220811||||||F|||20220811233336|49D5191021||||20220811233336||||Any lab USA^^^^^^XX^^^49D5191021|156 Slyvia Key^^Quincy^MI^49082^^^^Branch|||||QST
OBX|8|NM|30525-0^Age^LN^^^^2.68||7||||||F|||20220811233336|49D5191021||||20220811233336||||Any lab USA^^^^^^XX^^^49D5191021|156 Slyvia Key^^Quincy^MI^49082^^^^Branch|||||QST
OBX|9|CWE|95421-4^Resides in a congregate care setting^LN^^^^2.69||UNK^Unknown^NULLFL||||||F|||20220811233336|49D5191021||||20220811233336||||Any lab USA^^^^^^XX^^^49D5191021|156 Slyvia Key^^Quincy^MI^49082^^^^Branch|||||QST
OBX|10|CWE|95419-8^Has symptoms related to condition of interest^LN^^^^2.69||UNK^Unknown^NULLFL||||||F|||20220811233336|49D5191021||||20220811233336||||Any lab USA^^^^^^XX^^^49D5191021|156 Slyvia Key^^Quincy^MI^49082^^^^Branch|||||QST
OBX|11|CWE|75617-1^Residence type^LN^^^^2.68||285113009^Religious Institutional Residence^SCT||||||F|||20220811233336|49D5191021||||20220811233336||||Any lab USA^^^^^^XX^^^49D5191021|156 Slyvia Key^^Quincy^MI^49082^^^^Branch|||||QST
SPM|1|947347&Any facility USA&57D2109627&CLIA^753721&Any facility USA&57D2109627&CLIA||445297001^Swab of internal nose^SCT^^^^2.67|||MARTL^Martin-Lewis Agar^HL70048|71836000^Nasopharyngeal structure (body structure)^SCT^^^^2020-09-01||h6xhitmyx|G|||d4uipoq6|||20220811233336|20220811233336
'
  1. Verify output is the same!
  2. Go to the validate page in the GUI and verify it still works

Changes

  • Updated validation related tests
  • Added ability to use validation endpoint(s) without logging in

Checklist

Testing

  • Tested locally?
  • Ran ./prime test or ./gradlew testSmoke against local Docker ReportStream container?
  • (For Changes to /frontend-react/...) Ran npm run lint:write?
  • Added tests?

Process

  • Are there licensing issues with any new dependencies introduced?
  • Includes a summary of what a code reviewer should test/verify?
  • Updated the release notes?
  • Database changes are submitted as a separate PR?
  • DevOps team has been notified if PR requires ops support?

Linked Issues

Specific Security-related subjects a reviewer should pay specific attention to

Security Implications:

This PR makes a couple endpoints public, this means we must have rate limiting, which devops has said we have enabled. Furthermore, these endpoints currently do not display and sensitive information.

@arnejduranovic arnejduranovic self-assigned this Jan 24, 2023
@arnejduranovic arnejduranovic temporarily deployed to staging January 24, 2023 20:25 — with GitHub Actions Inactive
@github-actions
Copy link

github-actions bot commented Jan 24, 2023

Test Results

692 tests  +1   688 ✔️ +1   1m 10s ⏱️ +7s
  88 suites ±0       4 💤 ±0 
  88 files   ±0       0 ±0 

Results for commit c3b373c. ± Comparison against base commit 8b92a1e.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Jan 24, 2023

Integration Test Results

120 tests   120 ✔️  2m 26s ⏱️
  12 suites      0 💤
  12 files        0

Results for commit c3b373c.

♻️ This comment has been updated with latest results.

@arnejduranovic arnejduranovic temporarily deployed to staging January 24, 2023 20:54 — with GitHub Actions Inactive
@arnejduranovic arnejduranovic temporarily deployed to staging January 24, 2023 21:01 — with GitHub Actions Inactive
prime-router/docs/api/validate.yml Outdated Show resolved Hide resolved
@arnejduranovic arnejduranovic temporarily deployed to staging January 24, 2023 21:40 — with GitHub Actions Inactive
@arnejduranovic arnejduranovic added platform Platform Team API Tickets that include work to be completed on the ReportStream API labels Jan 24, 2023
@@ -178,4 +209,28 @@ class ValidateFunction(
)
.build()
}

/**
* Return [TopicSender] for a given schema if that schema exists. This lets us wrap the data needed by

Choose a reason for hiding this comment

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

🙏

"Internal",
Sender.Format.valueOf(format),
CustomerStatus.TESTING,
schemaName,
Copy link

@stephenkao stephenkao Jan 24, 2023

Choose a reason for hiding this comment

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

Is there any possible issue of validating a custom schema error messages through this? Like if someone makes a call to /validateWithSchema?schema=hl7%2fhcintegrations-covid-19&format=HL7 without being part of the hcintegrations Organization. I'd suppose not since the schemas are already open source and there couldn't really be a nefarious use case for this as far as I know, but just thought I'd ask!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Correct, we concluded that this would be OK. We are also OK with a user calling validateWithClient and "guessing" clients. There is no personal info at risk.

}

@Test
fun `test validate endpoint with okta dot-notation client header - full dotted name`() {
fun `test validate endpoint with format but missing schemaName`() {

Choose a reason for hiding this comment

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

Might also be a good idea to test against a call if the schema is provided in the query parameters but it can't be found here!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good idea, will test and update

@stephenkao
Copy link

Left a couple of very small comments, but this looks and works great! I'll defer approval to the rest of the Platform team, though -- thanks so much for hopping on this! ❤️

@arnejduranovic arnejduranovic temporarily deployed to staging January 25, 2023 15:43 — with GitHub Actions Inactive
@sonarcloud
Copy link

sonarcloud bot commented Jan 25, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Collaborator

@thetaurean thetaurean left a comment

Choose a reason for hiding this comment

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

Looks good! Also learned a lot reading through this which is always great.

One tiny comment on a comment.

HttpUtilities.internalErrorResponse(request)
}
}

/**
* Handles an incoming validation request after it has been authenticated via the /validate endpoint.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Slightly pedantic, but is the second part of this comment still valid (authenticated)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch! I can update this

if (sender != null && sender is HasSchema) {
schema = workflowEngine.metadata.findSchema(sender.schemaName)
if (schema == null) {
// Find schema via SCHEMA_PARAMETER parameter
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: You will need to refactor this as some point as this only supports the covid pipeline.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Noted, created #8073 to track this work.

@HttpTrigger(
name = "validate",
name = "validateWithClient",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just detect what parameter is being passed and run the proper validation? You should not have different API endpoints just to have different parameters.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thank you for your comment! If we have a single endpoint, then the user-facing documentation will look like so:

Screenshot 2023-01-25 at 12 58 39 PM

Notice, according to the docs, none of the parameters are NOT required, but actually they are. Passing no params is NOT valid, and there are special combos that are accepted:

  1. Client
  2. SchemaName + format (these params cannot be provided without the other)

The only way this would be clear to the user is if we explicitly added additional documentation specifying the valid combinations. Breaking it out into separate endpoints solved that:

Screenshot 2023-01-25 at 1 07 52 PM

Another idea may be to use path/route parameters instead, so like:

  1. api/validate/{client}
  2. api/validate/{schemaName}/{format}

But I think this is usually considered bad practice because route parameters should identify a resource in the system, for example:

  1. /users/{id}
  2. /organizations/{orgId}/members/{memberId}

In our case, the route parameters would not identify a resource, they would just be placing what are conceptually query parameters into the route parameters.

Compromise?

Would something like the following be better?

  1. api/validate/withClient (pass client in header, like we do today)
  2. api/validate/withSchema?schemaName="NAME&format="FORMAT"

Any additional thoughts or thoughts to what I said? I think this is a discussion worth having and I am willing to update to whatever makes most sense.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I should mention, if I am remembering my past experience with Java Spring Boot correctly, I believe you can specify the same endpoint with different query parameters and, with the proper annotations, it shows up in Swagger Documentation as separate endpoints and is very clear what is going on. Azure Function's HTTPTrigger does not support that but my guess is an Azure Web App, if we ever move to it, probably would. The nice thing about Spring Boot was it would automatically check to see if the required parameters were passed in, no additional code needed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Perhaps I can do something like the above but manually? Let me see what I can cook up...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay, I combined the endpoints and manually updated the yml to look like so:

Screenshot 2023-01-25 at 2 19 39 PM

probably should have done this in the first place, but didn't know I could put whatever in the path in yml

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay so turns out this is invalid openAPI, so I updated per the openAPI spec:

Screenshot 2023-01-25 at 3 28 25 PM

Doing it this way is what I was trying to avoid in the first place but:

  1. It's the recommended workaround here https://swagger.io/docs/specification/describing-parameters/
  2. I agree we should not have separate endpoints in this case

@arnejduranovic arnejduranovic temporarily deployed to staging January 25, 2023 20:18 — with GitHub Actions Inactive
@snesm snesm self-requested a review January 25, 2023 20:39
'400':
description: Bad Request

/validate?schema={schema}&format={format}:
Copy link
Contributor

Choose a reason for hiding this comment

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

Semantic error at paths./validate?schema={schema}&format={format}
Query strings in paths are not allowed.

I suspect we want to use oneOf: with the two different parameters: blocks intead.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hm I didn't get that error locally with my IDEA plugin. What are you using to generate this so I can try too? Will look into oneOf!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay I see this in https://editor.swagger.io/. Will try to find a work around, but oneOf not working so far

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated! Unfortunately, there is not a way to do what I want, the official openAPI docs have a section titled Parameter Dependencies here. I followed their suggestion:

OpenAPI 3.0 does not support parameter dependencies and mutually exclusive parameters. There is an open feature request at OAI/OpenAPI-Specification#256. What you can do is document the restrictions in the parameter description and define the logic in the 400 Bad Request response.

In the future, I will make sure to validate swagger changes @ https://editor.swagger.io/

@arnejduranovic arnejduranovic temporarily deployed to staging January 25, 2023 21:24 — with GitHub Actions Inactive
Copy link
Member

@jimduff-usds jimduff-usds left a comment

Choose a reason for hiding this comment

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

Nice work!

Copy link
Contributor

@carlosfelix2 carlosfelix2 left a comment

Choose a reason for hiding this comment

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

Your PR description needs to include test steps on how to test the new endpoint. What sample data to submit, what to expect. I did not have time to try it out.

@@ -70,27 +73,40 @@ abstract class RequestFunction(
routeTo.filter { workflowEngine.settings.findReceiver(it) == null }
.forEach { actionLogs.error(InvalidParamMessage("Invalid receiver name: $it")) }

var sender: Sender? = null
Copy link
Contributor

Choose a reason for hiding this comment

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

This new code is not covered by unit tests

Copy link
Collaborator Author

@arnejduranovic arnejduranovic Jan 26, 2023

Choose a reason for hiding this comment

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

This abstract class, and specifically this method, is exercised via the tests that test its subclasses: ReportFunctionTests and ValidateFunctionTests. The new (and old) ValidateFunctionTests in particular exercise the code highlighted here, through their calls to ValidateFunction.processRequest. We currently do not have any direct unit tests for the abstract class RequestFunction, but if you would like me to test that method directly in this ticket I can. I just didn't see the need to.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Also, I just simplified this code, moving almost all schema/format logic to getDummySender to reduce redundancy with the logic in ValidateFunction. So, I added tests for getDummySender since its more complicated now.

@arnejduranovic arnejduranovic temporarily deployed to staging January 26, 2023 22:08 — with GitHub Actions Inactive
@arnejduranovic arnejduranovic temporarily deployed to staging January 26, 2023 22:09 — with GitHub Actions Inactive
@arnejduranovic arnejduranovic temporarily deployed to staging January 27, 2023 14:44 — with GitHub Actions Inactive
@arnejduranovic arnejduranovic merged commit b62c83d into master Jan 27, 2023
@arnejduranovic arnejduranovic deleted the platform/7927 branch January 27, 2023 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Tickets that include work to be completed on the ReportStream API platform Platform Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Validation API should be public, and accept either a schema name or an organization.sender name.
6 participants