Git Product home page Git Product logo

Comments (7)

Korbeil avatar Korbeil commented on June 19, 2024

Hi :) Could you provide the OpenAPI schema that is doing this error ?

from janephp.

paulo-jay avatar paulo-jay commented on June 19, 2024

Hi,

Sorry for the delay, I was on holiday.

The OpenApi schema can be found at this url : https://demo.tagpay.fr/doc/public/distributor.yml

from janephp.

Korbeil avatar Korbeil commented on June 19, 2024

So, I did some research about your bug.

First, I can reproduce it in local 🎉 But that's where the problems begin ...
Your bug is caused by OpenApi Schema normalization (here https://github.com/janephp/janephp/blob/master/src/OpenApi/JaneOpenApi.php#L58).
It seems he can't understand reference that are themself a variable (in your case it's an object called UserProfileId which cause all that trouble cause it's a string (and should be not regognize as an object).

I'll pause my search here for now, but that's a nice bug we got here 😄

from janephp.

paulo-jay avatar paulo-jay commented on June 19, 2024

Thanks for your investigation !
Indeed references will not always point to an object type.
We use references pointing to "base types" to factorize descriptions or constraints.
In this case, we consider "IDs" as meaningful types because it can be used in multiple endpoints, and are not just "data" : they are pointing to an identified resource.

Please tell me if you need any help fixing the bug.

from janephp.

Korbeil avatar Korbeil commented on June 19, 2024

So I tried with simple tests with reference of simple type in both model and response and both are working ok. I think there is a bit more about your case.

from janephp.

Korbeil avatar Korbeil commented on June 19, 2024

And here is the minimal reproducer:

{
    "openapi": "3.0.0",
    "info": {
        "version": "",
        "title": ""
    },
    "paths": {
        "/foo": {
            "get": {
                "operationId": "foo",
                "parameters": [
                    {
                        "name": "bar",
                        "in": "query",
                        "schema": {
                            "$ref": "#/components/schemas/Bar"
                        },
                        "required": true
                    }
                ],
                "responses": {
                    "default": {
                        "description": "Default response"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "Bar": {
                "type": "string"
            }
        }
    }
}

Reference as type is correctly handled everywhere except in endpoint parameters.

from janephp.

Ocramius avatar Ocramius commented on June 19, 2024

It seems like the solution in #126 handles $ref directly inside "schema" declarations under "parameters", but will crash with multiple jumps in references:

openapi: 3.0.3
info:
  title: issue-108-edge-case
  description: irrelevant
  version: v1
paths:
  /an-endpoint:
    get:
      operationId: an-id
      parameters:
      - $ref: "#/components/parameters/Offset"
      responses:
        200:
          description: a response
          content:
            application/json:
              schema:
                type: object
components:
  parameters:
    Offset:
      name: offset
      in: query
      schema:
        $ref: "#/components/schemas/Offset"
      description: The number of items to skip.
      required: false
      example: 20
  schemas:
    Offset:
      type: integer
      format: int32
      description: The number of items to skip.
      minimum: 0
      default: 0

EDIT: forking and creating a ticket. The problem is easily highlighted by the type-checker.
EDIT 2: yo, really need to start dropping PHP < 8.1, y'all :|

from janephp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.