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

Sort docs by group, group_index #148

Merged
merged 1 commit into from
Feb 25, 2023
Merged

Conversation

kitloong
Copy link
Collaborator

Fix #143

@codecov-commenter
Copy link

codecov-commenter commented Feb 25, 2023

Codecov Report

Merging #148 (0ba821a) into master (ec08343) will increase coverage by 0.59%.
The diff coverage is 87.50%.

@@             Coverage Diff              @@
##             master     #148      +/-   ##
============================================
+ Coverage     43.40%   44.00%   +0.59%     
- Complexity      164      165       +1     
============================================
  Files             6        6              
  Lines           470      475       +5     
============================================
+ Hits            204      209       +5     
  Misses          266      266              
Impacted Files Coverage Δ
src/LaravelRequestDocs.php 72.51% <87.50%> (+0.53%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@kevincobain2000 kevincobain2000 merged commit 374f4f1 into master Feb 25, 2023
@kevincobain2000 kevincobain2000 deleted the feature/group-fix branch February 25, 2023 08:26
@@ -119,15 +119,23 @@ public function filterByMethods($docs, $get, $post, $put, $path, $delete, $head)

public function groupDocs($docs, $group = 'default')
{
if ($group === 'default') {
Copy link
Member

Choose a reason for hiding this comment

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

better than before, but still not quite there.
Screen Shot 2023-02-25 at 17 28 30

    {
        "uri": "api/v1/health",
        "methods": [
            "GET"
        ],
        "middlewares": [
            "api"
        ],
....
        ],
        "group": "api/v1/health",
        "group_index": 0
    },
    {
        "uri": "api/v1/not-health",
        "methods": [
            "GET"
        ],

merged but will reopen the issue #143
Won't push new tag yet.

Copy link
Member

Choose a reason for hiding this comment

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

Loop on UI is here

{lrdDocsJson.map((lrdDocsItem) => (
lrdDocsItem.methods.map((method, methodIndex) => (
<div key={shortid.generate()}>
{(lrdDocsItem.group != null && lrdDocsItem.group != "" && lrdDocsItem.group_index == 0 && methodIndex == 0) && (
<li className="pt-5 text-slate-600">
{/* Only in case of controller names full path -> just controller name */}
{lrdDocsItem.group.split('\\').pop()}
</li>
)}
<li>
<AnchorLink href={'#' + method + lrdDocsItem.uri} className="flex flex-row px-0 py-1">
<span className={`method-${method} uppercase text-xs w-12 p-0 flex flex-row-reverse`}>
{method}
</span>
<span className="flex-1 p-0 text-sm text-left break-all">
{lrdDocsItem.uri}
</span>
</AnchorLink>
</li>
</div>
))
))}

}

return $docs;
return collect($groupDocs)->sortBy(['group', 'group_index'])
Copy link
Member

Choose a reason for hiding this comment

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

Probably this


        return collect($groupDocs)->groupBy(['group', 'group_index'])
            ->values()
            ->flatten(2)
            ->toArray();

Copy link
Member

Choose a reason for hiding this comment

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

        $groupBy = ['group', 'group_index'];
        return collect($groupDocs)->groupBy($groupBy)
            ->values()
            ->flatten(count($groupBy))
            ->toArray();

Copy link
Member

Choose a reason for hiding this comment

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

Fixes here #150

Copy link
Member

@kevincobain2000 kevincobain2000 Feb 25, 2023

Choose a reason for hiding this comment

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

Fix is fine but
ah UT failed, so will revert changes c938063
Will wait for your pull req

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Group by including unrelated api routes
3 participants