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

Add a validator for documentation package names and base urls. #373

Merged
merged 9 commits into from
Apr 19, 2021

Conversation

Numerlor
Copy link
Contributor

@Numerlor Numerlor commented Aug 3, 2020

python-discord/bot#1014 will introduce a restriction on the package names to a-z, 0-9 and _ because they will be used directly for stats and will enforce base urls to end with slashes. This PR implements the restrictions on the site side.

Package names are used for stats in the bot and are restricted to
the a-z_ char set, a validator is added to accommodate this restriction
at the site admin side.
@Numerlor Numerlor requested a review from a team as a code owner August 3, 2020 20:25
@ghost ghost added the needs 2 approvals label Aug 3, 2020
@ghost
Copy link

ghost commented Aug 3, 2020

Thank you for contributing to Python Discord!

Please check out the following documents:

@Numerlor Numerlor marked this pull request as draft August 3, 2020 22:12
Some packages can contain them and are good for stats.
The move prevents it going through the line limit
and deeper nesting of parentheses from splitting up the string.
The validators kwarg expects an iterable of validators,
while a validator directly was being supplied.
@Numerlor Numerlor marked this pull request as ready for review August 4, 2020 14:30
@ghost
Copy link

ghost commented Aug 4, 2020

Thank you for contributing to Python Discord!

Please check out the following documents:

Copy link
Member

@lemonsaurus lemonsaurus left a comment

Choose a reason for hiding this comment

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

This looks good to me.

@ghost ghost removed the needs 1 approval label Sep 28, 2020
@MarkKoz MarkKoz added area: API Related to or causes API changes type: feature New feature or request labels Oct 8, 2020
Copy link
Member

@MarkKoz MarkKoz left a comment

Choose a reason for hiding this comment

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

You should document in the viewset that a 400 will be returned by the POST due to the regex validator failing.

@ghost ghost added the s: waiting for author Waiting for author to address a review or respond to a comment label Oct 8, 2020
Base automatically changed from master to main March 13, 2021 19:57
@jb3 jb3 requested a review from Akarys42 as a code owner March 13, 2021 19:57
@coveralls
Copy link

coveralls commented Mar 14, 2021

Coverage Status

Coverage remained the same at 100.0% when pulling fc4a9e2 on Numerlor:doc-validator into 93be3f4 on python-discord:main.

@Numerlor
Copy link
Contributor Author

You should document in the viewset that a 400 will be returned by the POST due to the regex validator failing.

Isn't the current documentation pointing the user to see the response on 400s enough?

### POST /bot/documentation-links
Create a new documentation link object.
#### Body schema
>>> {
... 'package': str,
... 'base_url': URL,
... 'inventory_url': URL
... }
#### Status codes
- 201: returned on success
- 400: if the request body has invalid fields, see the response for details

URLs without a trailing slash won't get properly joined by the bot
Adds compatibility with python-discord/bot@bc25bfd's changes

The styling of how the regex decorator is constructed was changed to be consisted with the
function validator
@Numerlor Numerlor changed the title Add a validator for documentation package names. Add a validator for documentation package names and base urls. Mar 26, 2021
@MarkKoz MarkKoz enabled auto-merge April 19, 2021 07:01
@MarkKoz MarkKoz merged commit 8cd9e3b into python-discord:main Apr 19, 2021
@Numerlor Numerlor deleted the doc-validator branch April 19, 2021 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: API Related to or causes API changes s: waiting for author Waiting for author to address a review or respond to a comment type: feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants