wol-soft / wol-soft/php-json-schema-model-generator

additionalProperties: { ... some object } can seemingly cause issues (at least depending on nesting with $ref)

Open
#116 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
83
Forks
21
PR merge metrics
No merged PRs in 30d

Description

this is so i will remember to continue here next week, I will add code example via PR later on next week

but something like this:

{
                            "type": "object",
                            "description": "Forecasted metric values at this budget level. Keys are either forecastable-metric values for delivery/engagement (impressions, reach, spend, etc.) or event-type values for outcomes (purchase, lead, app_install, etc.). Values are ForecastRange objects (low/mid/high). Use { \"mid\": value } for point estimates. Include spend when the platform predicts it will differ from budget.",
                            "additionalProperties": {
                              "title": "Forecast Range",
                              "description": "A forecast value with optional low/high bounds. The mid value represents the most likely outcome. When low and high are provided, they represent conservative and optimistic estimates respectively.",
                              "type": "object",
                              "properties": {
                                "low": {
                                  "type": "number",
                                  "description": "Conservative (low-end) forecast value",
                                  "minimum": 0
                                },
                                "mid": {
                                  "type": "number",
                                  "description": "Expected (most likely) forecast value",
                                  "minimum": 0
                                },
                                "high": {
                                  "type": "number",
                                  "description": "Optimistic (high-end) forecast value",
                                  "minimum": 0
                                }
                              },
                              "required": [
                                "mid"
                              ],
                              "additionalProperties": true
                            }
                          }

will cause dtos that cannot represent the data. Maybe only if it is used with $ref i will double check and create an atomic example next week. Is used here:
https://github.com/adcontextprotocol/adcp/blob/main/dist/schemas/3.0.0-beta.3/bundled/media-buy/get-products-response.json#L1926

is removed in rc2 of the schema, but other places, maybe, still use this functionality or similar one e.g. here somewhat similar:
https://github.com/adcontextprotocol/adcp/blob/main/dist/schemas/3.0.0-rc.2/bundled/media-buy/package-request.json#L7533

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the referenced bundled schemas at dist/schemas/3.0.0-beta.3/bundled/media-buy/get-products-response.json and dist/schemas/3.0.0-rc.2/bundled/media-buy/package-request.json. Reproduce generation for nested additionalProperties objects, especially when combined with $ref, and reduce it to an atomic schema example. Done means the generated PHP DTO can represent and validate the described nested data.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.