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

groups.order now supports * wildcard, so you can put groups at the end #731

Merged
merged 1 commit into from
Sep 18, 2023

Conversation

ProjectZero4
Copy link
Contributor

…to determine where in the ordering all unspecified groups will be placed.

Opening this one as a Draft so we can talk about implementation/config @shalvah. Hopefully this is a feaure Scribe can support.

This PR is adding a feature which allows you to bury endpoints at the bottom of the list for example older versions that you don't want consumers going to first.

This is done with the following config:

return [
// ...top of config
        'order' => [
            'First Group',
            'Second Group',
            '*',
            'Last Group',
        ],
// ...rest of config
];

This will generate the groups like the screenshot below:

image

@shalvah
Copy link
Contributor

shalvah commented Sep 16, 2023

Makes sense (and no new config items😆); I like.👍

@shalvah
Copy link
Contributor

shalvah commented Sep 16, 2023

Question: did you find it difficult to contribute (is knowing where to look, what goes where, how to add tests, etc)?

@ProjectZero4
Copy link
Contributor Author

Just been playing around with the current implementation, it loses the natural order sort so I'll have a re think on this

@ProjectZero4
Copy link
Contributor Author

Question: did you find it difficult to contribute (is knowing where to look, what goes where, how to add tests, etc)?

There's always been tests related to what I've changed to it's easy to find them. In terms of the code, my ide gets me around fast so I don't really have to spend time looking for things that much

…to determine where in the ordering all unspecified groups will be placed
@ProjectZero4
Copy link
Contributor Author

This new implementation retains the natural sorting functionality for the wildcard groups

@ProjectZero4 ProjectZero4 marked this pull request as ready for review September 16, 2023 21:37
@shalvah
Copy link
Contributor

shalvah commented Sep 16, 2023

Btw, does it also work for subgroups?

            '10. Group 10',
            '13. Group 13' => [
                'SG B' => [
                    'POST /api/action13d',
                    '*',
                    'GET /api/action13a',
                ],
                '*',
                'SG A',
                'PUT /api/action13c',
            ],
        ]]);

@shalvah
Copy link
Contributor

shalvah commented Sep 16, 2023

Could you send a PR to the docs repo as well? https://github.com/knuckleswtf/scribe-docs

I think the places you need to update are https://scribe.knuckles.wtf/laravel/reference/config#order and https://scribe.knuckles.wtf/laravel/tasks/sorting-and-inheritance#sorting-endpoints-and-groups. Can probably just edit them from the GitHub UI.

@ProjectZero4
Copy link
Contributor Author

Btw, does it also work for subgroups?

            '10. Group 10',
            '13. Group 13' => [
                'SG B' => [
                    'POST /api/action13d',
                    '*',
                    'GET /api/action13a',
                ],
                '*',
                'SG A',
                'PUT /api/action13c',
            ],
        ]]);

Not currently, it seems the sub group sorting is done differently to the top level groups.

We could look at adding support for that later?

@ProjectZero4
Copy link
Contributor Author

I've created knuckleswtf/scribe-docs#25 for the documentation.

I'm having trouble getting docusaurus to start however. So I have not been able to confirm what this looks like.

Below is the error I get running yarn start

yarn run v1.22.19
$ cross-env NODE_OPTIONS=docusaurus start
events.js:377
      throw er; // Unhandled 'error' event
      ^

Error: spawn start ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:277:19)
    at onErrorNT (internal/child_process.js:472:16)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:283:12)
    at onErrorNT (internal/child_process.js:472:16)
    at processTicksAndRejections (internal/process/task_queues.js:82:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn start',
  path: 'start',
  spawnargs: []
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@shalvah shalvah changed the title * You can now put groups at the bottom of the list by using the "*" … groups.order now supports * wildcard, so you can put groups at the end Sep 18, 2023
@shalvah
Copy link
Contributor

shalvah commented Sep 18, 2023

No worries, that's JavaScript for you. Top-level support is fine for now.

@shalvah shalvah merged commit ea52307 into knuckleswtf:master Sep 18, 2023
6 checks passed
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.

2 participants