Comments (5)
Hi !
RefProperty
is only used for responses. I had something in mind like:
#[Property(["field1.subfield1" => "string", "field1.subfield2" => "int])]
But now I'm thinking of automatically generating the RequestBody ref directly from the Request object (in your case CalculationRequest
). Basically this means you would declare your schema in your request file and in your controller, just the POST and Response.
Maybe this would include implementing an interface to "find" the request body or just any class inheriting symphony's Request object.
What do you think ?
Obviously I'm open to PRs but if needed I can do it
from openapi-php-attributes.
The variant with the Request object looks very interesting. But in general, this will not solve my problem, it would be great to explicitly specify child schemas. In my example, it would look something like this:
#[
Schema(name: CalculationRequest::class),
Property(PropertyType::STRING, "service"),
Property(PropertyType::REF, "shippingAddress"),
PropertyRef(Address::class),
Property(PropertyType::REF, "deliveryAddress"),
PropertyRef(Address::class),
]
class CalculationRequest extends JsonRequest implements ValidateRequestInterface
{
private string $service;
private Address $shippingAddress;
private Address $deliveryAddress;
}
#[
Schema(name: Address::class),
Property(PropertyType::STRING, "region"),
Property(PropertyType::STRING, "city"),
Property(PropertyType::STRING, "address"),
Property(PropertyType::STRING, "fullAddress"),
Property(PropertyType::BOOLEAN, "isTerminal"),
]
class Address
{
public string $region;
public string $city;
public string $address;
public string $fullAddress;
public bool $isTerminal;
}
How do you think?
I think I can implement this in a separate PR.
from openapi-php-attributes.
That looks good !
Maybe the syntax should be like the Response
attribute where you can put a reference in the attributes.
You could then have:
#[
Schema,
Property(name: "shippingAddress", ref: Address::class)
]
class CalculationRequest {
}
Though, this could just be a shortcut ...
from openapi-php-attributes.
Published in version 1.2 and 1.3
from openapi-php-attributes.
Thank you @uderline 🙏
from openapi-php-attributes.
Related Issues (11)
- why not publish this package in packagist? HOT 1
- path-parms thats not a function-param? HOT 3
- Undefined array key "security" HOT 1
- invalid output/json
- invalid securityScheme HOT 2
- Extending functionality HOT 7
- Different outputs generated on different systems HOT 2
- Allow BackedEnums for OpenApiGenerator\Attributes\Property HOT 2
- Require mandatory fields but omit empty optional fields HOT 1
- Error when not defined `Server` attribute
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 openapi-php-attributes.