openapi-processor/openapi-processor-spring

Endpoint parameters not parsed

Closed this issue · 5 comments

Hi,

I've found that parameters written at endpoint level are not parsed.
Here is an example

openapi-processor-mapping: v2

options:
  package-name: be.unamur.nuts.web.api
  javadoc: true
openapi: 3.0.2
info:
  title: nuts
  version: '1.0'
  contact: {}
  description: 'Test bug'
servers:
  - url: 'http://localhost:8080'
tags:
  - name: user
    description: Everything about users
paths:
  '/users/{userId}':
    parameters:
      - schema:
          type: integer
        name: userId
        in: path
        required: true
        description: Id of an existing user.
    get:
      summary: Get User Info by User ID
      tags:
        - user
      responses:
        '200':
          description: User Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
              examples:
                Get User Alice Smith:
                  value:
                    id: 142
                    firstName: Alice
                    lastName: Smith
                    email: alice.smith@gmail.com
                    dateOfBirth: '1997-10-31'
                    emailVerified: true
                    signUpDate: '2019-08-24'
        '404':
          description: User Not Found
      operationId: get-users-userId
      description: Retrieve the information of the user with the matching user ID.

components:
  schemas:
    User:
      title: User
      type: object
      description: ''
      x-examples:
        Alice Smith:
          id: 142
          firstName: Alice
          lastName: Smith
      properties:
        id:
          type: integer
          description: Unique identifier for the given user.
        firstName:
          type: string
          description: The firstname of the user
        lastName:
          type: string
          description: The lastname of the user
      required:
        - lastName
  examples: {}

The result is the following Interface:

public interface UserApi {
    @GetMapping(
        path = {"/users/{userId}"},
        produces = {"application/json"}
    )
    User getUsersUserId();
}

spring processor version: 1.0.0.M20
maven plugin version: 1.0.0.M2

The userId should be used by the function

interesting, this works with the swagger parser but fails with openapi4j.

Workaround maybe <parser>SWAGGER</parser>.

Thanks for reporting.

Thank you
I've tested your workaround with SWAGGER parser.

That works with the version 1.0.0.M20 but I must add another plugin dependency, unless it fails :

<dependency>
    <groupId>com.fasterxml.jackson.dataformat</groupId>
    <artifactId>jackson-dataformat-yaml</artifactId>
</dependency>

If I don't the plugin doesn't find the method com.fasterxml.jackson.dataformat.yaml.YAMLFactory.builder()

With the last spring processor version (2021.1), it doesn't work but that's probably not due to the SWAGGER parser.
The error is that the io/openapiprocessor/api/v1/OpenApiProcessor class is required but missing.

Uhhh :-(

that is probably an issue with the maven plugin. It think it needs an update to work with the 2021 version. That is already high on my todo list.

Cool 😃 Thank you !

Hi,

published spring 2021.2 and maven-plugin 2021.1.