jhthorsen / openapi-client

A client for talking to an Open API powered server
11 stars 17 forks source link

Add warning for paths without operationId #16

Closed nfg closed 5 years ago

nfg commented 5 years ago

Hello! I was trying out OpenAPI::Client, and I had to add a bunch of dump statements to figure out why it wasn't creating any methods for the paths in the specfile. It turned out to be because the specfile wasn't setting operationId, which is required by the client to generate methods. Hopefully this will help out anyone trying to figure this out in the future.

Let me know if there's anything I should change.

Cheers!

jhthorsen commented 5 years ago

I don't understand this PR. Wouldn't you have to know the operationId to know which method to call and then you would see that there's no operationId if you can't find it?

I'm not totally against the PR, I just think the issue is backwards.

nfg commented 5 years ago

I didn't realize that operationId is an optional field, so I didn't understand why the methods weren't being generated. You're right, it's not the client's problem. But I would've figured it out faster if the client printed out a warning in debug mode.

However, you could also add a note to the documentation, like maybe

=head1 DEBUGGING

=over

=item The environment variable C<OPENAPI_CLIENT_DEBUG> can be used to turn on debugging logs.

=item Path definitions must have "operationId" set to be callable.

=back
jhthorsen commented 5 years ago

It's all over the documentation that it uses operationId: