Skip to content
This repository was archived by the owner on Jun 4, 2024. It is now read-only.

Generated REST URL rules should allow dot in URL #113

Closed
SOHELAHMED7 opened this issue Oct 1, 2022 · 3 comments · Fixed by SOHELAHMED7/yii2-openapi#15
Closed

Generated REST URL rules should allow dot in URL #113

SOHELAHMED7 opened this issue Oct 1, 2022 · 3 comments · Fixed by SOHELAHMED7/yii2-openapi#15
Assignees
Labels
enhancement New feature or request generator-feature Functionality missing from the generator
Milestone

Comments

@SOHELAHMED7
Copy link
Contributor

Lets say I have path /mail/domain/{name} in OpenAPI.

REST URL rules generated for it will be

GET mail/domain/<name:[\w-]+>

Above rule will not function for URL http://example.com/mail/domain/github.com

because github.com have dot (.)

Regex to include dot (.) will be mail/domain/<name:[\w.-]+>. So API generator should generate this URL rule to consider dot.

@cebe cebe moved this to 🆕 New in yii2-openapi Project Jan 27, 2023
@cebe cebe moved this from 🆕 New to 📋 Backlog in yii2-openapi Project Jan 27, 2023
@cebe
Copy link
Owner

cebe commented Jan 27, 2023

Regex should be customizable

@cebe cebe added this to the 2.0 milestone Jan 27, 2023
@cebe cebe moved this from 📋 Backlog to 🔖 Ready in yii2-openapi Project Jan 27, 2023
@cebe cebe added enhancement New feature or request generator-feature Functionality missing from the generator labels Jan 27, 2023
@SOHELAHMED7
Copy link
Contributor Author

Regex should be customizable at which level?

At lib config in PHP:

$generator = new ApiGenerator([
    ...
    'regex' => '[\w-]', <--- new config
    ...
]);

or for every path in OpenAPI:

# OpenAPI spec

paths:

  '/company/{companyId}/bank-accounts':
    parameters:
      - name: companyId
        in: path
        description: ID of the company.
        x-regex: '[\w-]'     <--- new config
        required: true
        schema:
          type: integer


@cebe
Copy link
Owner

cebe commented Feb 21, 2023

Regex should be customizable at which level?

for path in OpenAPI, we can check the pattern on the schema:

# OpenAPI spec

paths:

  '/domains/{domainname}':
    parameters:
      - name: domainname
        in: path
        description: dns domain name
        required: true
        schema:
          type: string
          pattern: '^[a-z-]$'

https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-00#section-6.3.3
https://json-schema.org/understanding-json-schema/reference/regular_expressions.html

Note that ^ and $ should be removed when the value is inserted into yii routing rules.

SOHELAHMED7 added a commit to SOHELAHMED7/yii2-openapi that referenced this issue Mar 1, 2023
…should-allow-dot-in-url

Draft - Generated REST URL rules should allow dot in URL cebe#113
@github-project-automation github-project-automation bot moved this from 🔖 Ready to ✅ Done in yii2-openapi Project Mar 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request generator-feature Functionality missing from the generator
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants