You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The documentation is a bit sparse on generating JSON Schemas programmatically,
To generate JSON Schemas programmatically, use the api_platform.json_schema.schema_factory service.
In particular, I want to build a schema from data, not from an existing class. That is, I'm trying to generate a schema to give some structure to my json blobs.
So I'm looking for an example that is something like
functiongenerateSchemaController(
SchemaFactoryInterface$schemaFactory
): Response
{
// this is fictional, I'm not at all sure what it's supposed to be.$property = newProperty('age', type: 'integer', 'minimum' => 18);
$schemaFactory->addProperty($property);
$json = $schemaFactor->generate();
returnnewJsonResponse($json);
}
I see that there are classes for Property and Definition, but I'm not sure how to use them to generate a schema.
I've looked at a few other tools, but ApiPlatform is much more complete, I think an example that doesn't require a PHP class would help a lot. Thanks.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
The documentation is a bit sparse on generating JSON Schemas programmatically,
In particular, I want to build a schema from data, not from an existing class. That is, I'm trying to generate a schema to give some structure to my json blobs.
So I'm looking for an example that is something like
I see that there are classes for Property and Definition, but I'm not sure how to use them to generate a schema.
I've looked at a few other tools, but ApiPlatform is much more complete, I think an example that doesn't require a PHP class would help a lot. Thanks.
Beta Was this translation helpful? Give feedback.
All reactions