openapi-processor / openapi-processor-core

moved into openapi-processor-base
Apache License 2.0
7 stars 5 forks source link

Reference parameter not working #19

Closed schlagi123 closed 4 years ago

schlagi123 commented 4 years ago

With following YAML is valid OpenAPI but the $ref of a parameter not work:


info:
  title: simple query parameters
  version: 1.0.0

paths:
  /query:
    get:
      tags:
        - endpoint
      parameters:
        - $ref: "#/components/parameters/MyParameter"
      responses:
        '200':
          description: plain text response
          content:
            plain/text:
              schema:
                type: string

components:
  parameters:
    MyParameter:
      in: query
      name: foo
      schema:
        type: string```
hauner commented 4 years ago

This works with the swagger parser but not with the openapi4j parser.

Workaround is to remove parser 'OPENAPI4J' from the processor config.

schlagi123 commented 4 years ago

I find out, that this issue is fixed in the version 1.0.4 of the openapi4j (https://github.com/openapi4j/openapi4j/issues/131, https://github.com/openapi4j/openapi4j/releases/tag/1.0.4)

In one of the last commits you updated this version already, but you do not release a new version (https://github.com/openapi-processor/openapi-processor-core/commit/1f2dc87b4032a8314709b07c9d7a19972b719499#diff-c197962302397baf3a4cc36463dce5ea)

hauner commented 4 years ago

it still fails with openapi4j 1.0.4. Problem is that parameter $refs are not resolved by the processor.

hauner commented 4 years ago

see also #24 in case you use non schema refs with the openapi4j parser.

mpet commented 5 months ago

@hauner We checked the release 1.0.4 in openapi4j and it claimed to have fixed the issue. We tried it and it still does not work. Then we checked the actual ticket and found the comment from @schlagi123 to this ticket.

How does this repo relate to https://github.com/openapi-processor related to openapi4j? We have a repo that depends on openapi4j ( that now seems archived). Is there a fix for this issue.

hauner commented 5 months ago

There is no relation to openapi4j.

openapi-processor does generate Java code from OpenAPI. It can use different OpenAPI parsers to read the OpenAPI. It supports the swagger parser, my own parser (https://github.com/openapi-processor/openapi-parser) and openapi4j.

To use parameter $refs with openapi4j you have to resolve the $ref in your code.

That's what openapi-processor does: https://github.com/openapi-processor/openapi-processor-base/blob/04924a62093f494813158fb8d82959b61373fa9f/openapi-processor-core-parser-openapi4j/src/main/kotlin/io/openapiprocessor/core/parser/openapi4j/RefResolverNative.kt