Skip to content

Endpoint parameters not parsed #122

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

Closed
rombru opened this issue Feb 26, 2021 · 5 comments
Closed

Endpoint parameters not parsed #122

rombru opened this issue Feb 26, 2021 · 5 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@rombru
Copy link

rombru commented Feb 26, 2021

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: [email protected]
                    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

@hauner hauner added the bug Something isn't working label Feb 27, 2021
@hauner hauner self-assigned this Feb 27, 2021
@hauner hauner added this to the 2021.2 milestone Feb 27, 2021
@hauner
Copy link
Member

hauner commented Feb 27, 2021

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

Workaround maybe <parser>SWAGGER</parser>.

Thanks for reporting.

@rombru
Copy link
Author

rombru commented Feb 27, 2021

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.

@hauner
Copy link
Member

hauner commented Feb 27, 2021

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.

@rombru
Copy link
Author

rombru commented Feb 27, 2021

Cool 😃 Thank you !

@hauner
Copy link
Member

hauner commented Feb 28, 2021

Hi,

published spring 2021.2 and maven-plugin 2021.1.

@hauner hauner closed this as completed Feb 28, 2021
hauner added a commit to openapi-processor/openapi-processor-core that referenced this issue Mar 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants