OpenAPI document resolves custom configured REST path#1653
Merged
seantleonard merged 3 commits intomainfrom Aug 25, 2023
Merged
OpenAPI document resolves custom configured REST path#1653seantleonard merged 3 commits intomainfrom
seantleonard merged 3 commits intomainfrom
Conversation
…umentor. Removed usage of substring and instead use Trim().
seantleonard
commented
Aug 24, 2023
seantleonard
commented
Aug 24, 2023
seantleonard
commented
Aug 24, 2023
Aniruddh25
reviewed
Aug 25, 2023
Aniruddh25
reviewed
Aug 25, 2023
Aniruddh25
reviewed
Aug 25, 2023
Aniruddh25
approved these changes
Aug 25, 2023
Collaborator
Aniruddh25
left a comment
There was a problem hiding this comment.
Thanks for the quick investigation and fix! Few questions, but otherwise LGTM.
…omments to reflect expected input and output of formatting the rest path in openapi documentor. Updated test variable name to more concisely reflect test parameter purpose -> `configuredRestPath`
seantleonard
added a commit
that referenced
this pull request
Aug 25, 2023
## Why make this change? - Closes #1633 - The wrong 'path' value is generated in the OpenAPI description document created. This was observed when looking at the `/swagger` endpoint to see the REST endpoint documentation. - When an entity's REST path property is explicitly set AND includes a starting slash `/`, the openapidocumentor does not properly create the PATH used to access the entity in the REST endpoint. ## What is this change? - Correctly process an entity's REST path configuration. Before this change, the method at fault was improperly calling `Substring()` on the wrong variable. Although the variable was previously `restPath`, the value at the time of calling substring was the top-level entity name which did not have a starting slash `/`. - The variable `restPath` is modified depending on whether the entity has explicit rest path config. If no explicit rest path is configured, the top level entity name is returned as the resolved rest path. - Now, calling `entityRestSettings.Path.TrimStart('/')` will correctly remove a starting slash IF one exists. This accommodates the following formatting of the explicit rest path: 1. `/customRestPath` 2. `customRestPath` 3. `//customRestPath` -> while this option is not advisable to use in practice, we still support it and this PR is not meant to change that behavior. But for complete test coverage, this case is tested. ## How was this tested? - [x] Integration Tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why make this change?
/swaggerendpoint to see the REST endpoint documentation./, the openapidocumentor does not properly create the PATH used to access the entity in the REST endpoint.What is this change?
Substring()on the wrong variable. Although the variable was previouslyrestPath, the value at the time of calling substring was the top-level entity name which did not have a starting slash/.restPathis modified depending on whether the entity has explicit rest path config. If no explicit rest path is configured, the top level entity name is returned as the resolved rest path.entityRestSettings.Path.TrimStart('/')will correctly remove a starting slash IF one exists. This accommodates the following formatting of the explicit rest path:/customRestPathcustomRestPath//customRestPath-> while this option is not advisable to use in practice, we still support it and this PR is not meant to change that behavior. But for complete test coverage, this case is tested.How was this tested?