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

Validation tries to match path with parameters placed in components section #228

Closed
tlewowski opened this issue Oct 24, 2018 · 2 comments
Closed

Comments

@tlewowski
Copy link

When running a validation on a YAML file that has path parameters in components/parameters section, a warning is returned that path for the parameter cannot be located.

I looked briefly at the code and this seems to come from com.reprezen.kaizen.oasparser.val3.ParameterValidator class - checkPathParam method calls getPathString for a parameter which (I suppose) is in components section. getPathString fetches the name from parent (?) object, which is components/parameters section, which obviously does not have the path field (and should not have it, I think).

This check should probably be run only for inline parameters - for referenced ones it would be cool to expand and check in the target location, but at least there should be no warning for path parameters in components. Removing the parameter clears warnings, change of path matcher does not cause new ones to appear, so I guess validation is only done on definition site, not in the places where the parameter is actually referenced.

Reproduction data:

library: "com.reprezen.kaizen" % "openapi-parser" % "4.0.1-201809050415"

YAML file (abc.yaml):

openapi: 3.0.1
info:
  title: ABC
  version: '1'
paths:
  /end/{abc}:
    parameters:
    - $ref: '#/components/parameters/abc'

components:
  parameters:
    abc:
      in: path
      required: true
      name: abc
      schema:
        type: string

Java class (Swagger.java):

import com.reprezen.kaizen.oasparser.OpenApiParser;
import com.reprezen.kaizen.oasparser.model3.OpenApi3;
import com.reprezen.kaizen.oasparser.val.ValidationResults;

public class Swagger {
    private void run() throws Exception {
        OpenApi3 model = (OpenApi3) new OpenApiParser().parse(getClass().getClassLoader().getResource("abc.yaml").toURI(), true);

        for(ValidationResults.ValidationItem t: model.getValidationResults().getItems()) {
            System.out.println(t.getMsg());
        }
    }

    public static void main(String[] args) throws Exception {
        new Swagger().run();
    }
}

actual output: Could not locate path for parameter 'abc'
expected output: `` (empty)

@tedepstein
Copy link
Contributor

@tlewowski , thanks for submitting the issue. We are working heads-down on a related project right now, so most likely will not be able to respond until next week. Just wanted to let you know we saw this, and will respond properly ASAP.

@tedepstein
Copy link
Contributor

Fixed in #237.

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

No branches or pull requests

2 participants