Skip to content

Access extension properties like x-foo-bar as x_foo_bar #88

New issue

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

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

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rv1971
Copy link
Contributor

@rv1971 rv1971 commented Dec 14, 2020

The OpenAPI specification allows for extension properties whose names must start with x-, citing x-internal-id as an example. Since such a property cannot be accessed as $obj->x-internal-id, the present commit translates the name so that it can be accessed as $obj->x_internal_id.

The OpenAPI specification allows for extension properties whose names
must start with `x-`, citing `x-internal-id` as an example. Since such
a property cannot be accessed as `$obj->x-internal-id`, the present
commit translates the name so that it can be accessed as
`$obj->x_internal_id`.
@cebe
Copy link
Owner

cebe commented Dec 15, 2020

Since such a property cannot be accessed as $obj->x-internal-id

it is possible to access these like $obj->{'x-internal-id'}. Converting the name is a bit arbitrary, need to think about it.
A better solution might be to implement ArrayAccess interface to allow $obj['x-internal-id'].

Linking for reference: http://spec.openapis.org/oas/v3.0.3#specification-extensions

@cebe cebe added the enhancement New feature or request label Dec 15, 2020
@cebe cebe added this to the 1.6.0 milestone Dec 15, 2020
@cebe
Copy link
Owner

cebe commented Oct 13, 2021

realted to #121

@cebe cebe removed this from the 1.6.0 milestone Feb 9, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants