Apicurio / apicurio-studio

Open Source API Design
https://www.apicur.io/studio/
Apache License 2.0
976 stars 493 forks source link

can't add path have PathParameter #894

Open masa423 opened 5 years ago

masa423 commented 5 years ago

i used OpenAPI3.

i wanted to add this API path, /{paramA},{paramB}/{filename}.{extension} but dialog say "Enter a valid Path"(red bold), and can't click add button.

i would tried to other pattern, /{paramA} -> OK /{paramA}/{paramB} -> OK /filename.{extension} -> OK /{paramA},{paramB} -> NG /{filename}.{extension} -> NG

swagger editor does not error those path.

Is it a restrict of apicurio studio? Will apicurio support those paths?

EricWittmann commented 5 years ago

This is a bit of an ongoing issue with the editor and I think is a bug. I think the editor should be very permissive in what it allows you to do, and we should have validation pick up potential problems instead (and then users can decide to disable certain validation rules if they choose).

But for now, you can work around this by using the Source tab to create/edit a path name.

masa423 commented 5 years ago

thanks.

I edited it in the source tab and could added these path.

but validator is reports error( path is invalid ). Is this a similar bug?

I will try disable validation rule temporarily.

EricWittmann commented 5 years ago

Let me know if you have any trouble disabling the validation rule. You have to create a custom validation profile and then configure the rules however you want. Then you need to apply that validation profile to your API when editing it. We still have some improvements to make linking all that stuff together in the UI in a more intuitive way, but it works OK right now I hope. :)

masa423 commented 5 years ago

i disabled "Invalid Path Segment" rule and applied to API.

but, validator is reported "paramB not found" and "extension not found".

Am I using a path format that is not allowed by OpenAPI3 or RFC6570?

Or apicurio's validator is wrong?

EricWittmann commented 5 years ago

You're seeing those errors most likely because you have not defined those path parameters in the Path Parameters section of your API design. For example:

image

So your path template has some path parameter variable names, but you haven't defined those path parameters. Of course, that's another validation problem that you could turn off if you wanted.

masa423 commented 5 years ago

Thanks.

image

image

but, I created parameter. validator still report to 'Parameter not found'.

openapi: 3.0.2
info:
    title: TestAPI
    version: 1.0.0
paths:
    '/{paramA},{paramB}/{filename}.{extension}':
        get:
            responses:
                '200':
                    description: OK
        parameters:
            -
                name: paramA
                in: path
                required: true
            -
                name: paramB
                in: path
                required: true
            -
                name: filename
                in: path
                required: true
            -
                name: extension
                in: path
                required: true
EricWittmann commented 4 years ago

Ah OK - it seems we need some additional improvements to the validators in this area. For now, the only thing you can do is also disable the "Path Parameter Not Found" rule, which would hide those problems. Of course, it will also hide any legitimate missing path params... :(

EricWittmann commented 4 years ago

But that's a workaround until we can get the problem fixed.

masa423 commented 4 years ago

thanks a lot.

I would like to disable these validators.

EricWittmann commented 4 years ago

Sure thing. Just edit your custom validation profile and disable the appropriate rule. Easy peasy. :)

Yuutakasan commented 4 years ago

When I try to design an API, I am in trouble because I cannot define it because of this problem.

EricWittmann commented 4 years ago

This problem isn’t fatal. You can either disable validation entirely or you can create a custom validation profile (in settings) and disable just the validation rules associated with path parameters. Or you can simply ignore the validation warning (until we can improve it). But it shouldn’t prevent you from designing your API...

Yuutakasan commented 4 years ago

Certainly it is possible to add a setting if the syntax check is turned off in the setting.

EricWittmann commented 4 years ago

Yes - that part is definitely a bug that needs to be fixed. But right now there is the workaround of changing the path in the Source tab.

rikiyaHayashi commented 4 years ago

Regarding this issue#894, I have a question.

Your situation is the same as mine, Has this issue already been resolved in the latest version(0.2.43)? Or is it being modified in the version under development(0.2.44)?

My development environment apicurio Version: (0.2.40)

EricWittmann commented 4 years ago

This issue has not yet been resolved and is not currently being modified - if you would like to take a look at a solution and submit a PR that would be very helpful. If not, that's OK too - we'll get this resolved in due time. :)

turutosiya commented 4 years ago

@EricWittmann

We're trying to make PR but I think I need your confirmation.

The current regex is (\/[^{}\/]*(\{[a-zA-Z_][0-9a-zA-Z_]*\})?)+ , It seems that it's expected just one parameter in one path separator pair.

/{this}/{is}/{ok}
/{this}is{ng}

What is this intended? or just no intention?

EricWittmann commented 4 years ago

Hi @turutosiya - sorry for the delay in my response. I've been on leave for a little while.

I think we should be more permissive in the regexp, so I think both of your examples should be allowed. There does not seem to be any specific requirement defined in the OpenAPI specification around this.