Skip to content

[Cherrypick] OpenAPI document resolves custom configured REST path (for 0.8 release)#1658

Merged
seantleonard merged 1 commit intorelease/0.8from
cherrypickOpenApiRestPathPatch
Aug 25, 2023
Merged

[Cherrypick] OpenAPI document resolves custom configured REST path (for 0.8 release)#1658
seantleonard merged 1 commit intorelease/0.8from
cherrypickOpenApiRestPathPatch

Conversation

@seantleonard
Copy link
Copy Markdown
Contributor

Cherry Picks commit from #1653 to 0.8 release branch as a patch.

## 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
Copy link
Copy Markdown
Collaborator

@Aniruddh25 Aniruddh25 left a comment

Choose a reason for hiding this comment

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

Thanks for the quick turnaround!

@seantleonard seantleonard enabled auto-merge (squash) August 25, 2023 23:32
@seantleonard seantleonard merged commit 3fef26a into release/0.8 Aug 25, 2023
@seantleonard seantleonard deleted the cherrypickOpenApiRestPathPatch branch August 25, 2023 23:50
@seantleonard seantleonard added the 🍒Cherrypick Cherry-picking another commit/PR label May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🍒Cherrypick Cherry-picking another commit/PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants