Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP - anyOf/oneOf primitive type array serialization wrong #5354

Open
baywet opened this issue Sep 6, 2024 · 0 comments
Open

PHP - anyOf/oneOf primitive type array serialization wrong #5354

baywet opened this issue Sep 6, 2024 · 0 comments
Labels
PHP priority:p2 Medium. For a p2 bug, generally have a work-around. Bug SLA <=30 days type:bug A broken experience
Milestone

Comments

@baywet
Copy link
Member

baywet commented Sep 6, 2024

related #5348

Repo

openapi: 3.0.3
info:
  title: Example
  description: Example
  version: 1.0.0
servers:
  - url: https://example.com/api
paths:
  '/example1':
    post:
      summary: Test error generation.
      description: "Test generating error with message property."
      operationId: postErrorGeneration
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Success'
components:
  schemas:
    Success:
      type: object
      oneOf:
        - type: string
        - type: array
          items:
            type: string

(or update to anyOf)

deseralization

public static function createFromDiscriminatorValue(ParseNode $parseNode): ItemPostRequestBody_tax_rates {
        $result = new ItemPostRequestBody_tax_rates();
        if ($parseNode->getStringValue() !== null) {
            $result->setItemPostRequestBodyTaxRatesString($parseNode->getStringValue());
        } else if ($parseNode->getCollectionOfObjectValues([string::class, 'createFromDiscriminatorValue']) !== null) {
            $result->setString($parseNode->getCollectionOfObjectValues([string::class, 'createFromDiscriminatorValue']));
        }
        return $result;
    }

Should instead call out getCollectionOfPrimitiveValues for the second case.

serialization

public function serialize(SerializationWriter $writer): void {
        if ($this->getItemPostRequestBodyTaxRatesString() !== null) {
            $writer->writeStringValue(null, $this->getItemPostRequestBodyTaxRatesString());
        } else if ($this->getString() !== null) {
            $writer->writeCollectionOfPrimitiveValues(null, $this->getString());
        }
    }

Should instead call writeCollectionOfPrimitiveValues for the second case, the conditions are inverted, and the property/getter getItemPostRequestBodyTaxRatesString should be an array of strings, not a simple string.

@baywet baywet added type:bug A broken experience PHP priority:p2 Medium. For a p2 bug, generally have a work-around. Bug SLA <=30 days labels Sep 6, 2024
@baywet baywet added this to the Backlog milestone Sep 6, 2024
@baywet baywet added this to Kiota Sep 6, 2024
@github-project-automation github-project-automation bot moved this to Needs Triage 🔍 in Kiota Sep 6, 2024
@baywet baywet moved this from Needs Triage 🔍 to Todo 📃 in Kiota Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PHP priority:p2 Medium. For a p2 bug, generally have a work-around. Bug SLA <=30 days type:bug A broken experience
Projects
Status: Todo 📃
Development

No branches or pull requests

1 participant