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

Parameter type problem with OpenAPI v3 #137

Closed
jusdude opened this issue Sep 12, 2019 · 2 comments
Closed

Parameter type problem with OpenAPI v3 #137

jusdude opened this issue Sep 12, 2019 · 2 comments
Labels

Comments

@jusdude
Copy link

jusdude commented Sep 12, 2019

When setting a parameter type as boolean with v3, I discovered that the value returned by validation->output() is not a JSON::PP::Boolean but a scalar. While debugging, I found out that the value was not going through the coerse function, and this was coming from the field type not being taken into account.

The type seems not to be retrieved correctly in lib/JSON/Validator/OpenAPI/Mojolicious.pm, line 69 :
my ($in, $name, $type) = @$p{qw(in name type)};

This works with v2, but with v3 the type should be within the schema property ($p->{schema}{type}) or even within the content property (according to the specs).

This is the YAML I used for my tests

paths:
  /context/db_default_dsn:
    get:
      operationId: getContextDbDefaultDsn
      x-mojo-name: get_context_db_default_dsn
      x-mojo-to: 'context#get_db_default_dsn'
      summary: "Retourne la base de donnée par défaut pour l'environnement"
      parameters:
        - name: ano
          in: query
          description: Indique si l'on veut la base anonyme
          schema:
            type: boolean
@jhthorsen
Copy link
Owner

I'm quite busy these days, so I would love to see a PR for this. I think I would start by adding a new test to https://github.com/jhthorsen/mojolicious-plugin-openapi/blob/master/t/v3.t which also cares about boolean, and not just integer and strings.

@jhthorsen
Copy link
Owner

Closed by #147.

jhthorsen pushed a commit that referenced this issue Oct 28, 2019
 - Fix /servers/url for OpenAPI v3 in SpecRenderer #148
 - Fix OpenAPI v3 parameter type #137 #147
   Contributor: SebMourlhou
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants