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

parse_swagger_schema: valid swagger doesn't parse #202

Open
mbana opened this issue Sep 17, 2018 · 2 comments
Open

parse_swagger_schema: valid swagger doesn't parse #202

mbana opened this issue Sep 17, 2018 · 2 comments

Comments

@mbana
Copy link

mbana commented Sep 17, 2018

attempting to parse this valid file fails:

https://github.com/OpenBankingUK/payment-initiation-api-spec/blob/master/dist/v1.1/payment-initiation-swagger.json

PhoenixSwagger.Validator.parse_swagger_schema("schemas/v1.1-payment-initiation-swagger.json")
...
12:37:01.864 [info]  Application swagger_validation_ex exited: exited in: SwaggerValidationExApplication.start(:normal, [])
    ** (EXIT) an exception was raised:
        ** (FunctionClauseError) no function clause matching in String.split/3
            (elixir) lib/string.ex:383: String.split(nil, "/", [])
            (phoenix_swagger) lib/phoenix_swagger/validator.ex:112: anonymous fn/3 in PhoenixSwagger.Validator.collect_schema_attrs/1
            (elixir) lib/enum.ex:1899: Enum."-reduce/3-lists^foldl/2-0-"/3
            (phoenix_swagger) lib/phoenix_swagger/validator.ex:109: anonymous fn/4 in PhoenixSwagger.Validator.collect_schema_attrs/1
            (elixir) lib/enum.ex:1294: Enum."-map/2-lists^map/1-0-"/2
            (elixir) lib/enum.ex:1298: anonymous fn/3 in Enum.map/2
            (stdlib) lists.erl:1263: :lists.foldl/3
            (elixir) lib/enum.ex:1915: Enum.map/2

looks like it failing around here: https://github.com/OpenBankingUK/payment-initiation-api-spec/blob/master/dist/v1.1/payment-initiation-swagger.json#L97 because $ref is not defined...

          {
            "name": "body",
            "in": "body",
            "description": "Setup a single immediate payment",
            "required": true,
            "schema": {
....

that is the schema is defined inline not using a reference.

This is a valid swagger file.

@mbuhot
Copy link
Contributor

mbuhot commented Sep 18, 2018

Yes it looks like the code assumes all parameter schemas are not defined inline.

A PR to support this case would be welcome 👍

@mbana
Copy link
Author

mbana commented Sep 18, 2018

I don't have much time on my hands at the moment. Are you likely to add this yourself in the near future, if not, I will just expose this library via REST to just do validation: https://github.com/apigee-127/sway.

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