Comments (7)
Hi :) Could you provide the OpenAPI schema that is doing this error ?
from janephp.
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.
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.
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.
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.
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.
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)
- [OpenApiCommon] Support Status code range HOT 1
- PHP 8.2 dynamic property deprecation HOT 2
- Symfony 6.3 - JaneObjectNormalizer should implement DenormalizerInterface::getSupportedTypes HOT 4
- Version 7.5.0 - Call to undefined method Jane\Component\OpenApiCommon\Registry\Schema::initOperationRelations()
- Custom Generators HOT 1
- $ref validator constraints overwrited by next property
- String property validator constraint always min length >=0
- Content type multipart/form-data with property object or boolean results in a fatal error
- ObjectTransformer is not available when custom MapperConfigurationInterface is processed HOT 2
- [Automapper] private properties in constructor are not mapped HOT 1
- [Automapper] problem when getter type is different from property type HOT 1
- Denormalizing invalid date or datetime results in TypeError HOT 1
- Allow openapi-file to be an URL
- BadRequestException is not marked abstract
- OAS 3.1: Declaring type as array results in TypeError (for nullable types) HOT 1
- Classes referenced as strings instead of via ::class
- Missing "default" response models when using "whitelisted-paths"
- Empty String for Date
- Warning: Undefined array key "" produces an Uncaught TypeError
- Content-Type `application/json;charset=UTF-8` is not serialized/deserialized as JSON
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from janephp.