cebe / cebe/php-openapi

Missing functions to remove elements ?

Open
#153 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
PHP
Stars
500
Forks
99
PR merge metrics
No merged PRs in 30d

Description

Hi,

I've been working on a project that would allow to take a full OAS Definition file and create a stripped down version using only a subset of the original endpoints, tags, webhooks, etc.

I want to remove internal functions based on a "x-internal" attributes.

I also want to create different versions of an api definition based on a "x-presentations" attributes.

So Far, I was able to remove uneeded:
- "paths" using paths->removePath('/path')
- "operations" using unset(pathItem->post)

But now I am struggling to find a way to remove other types of elements.
For example:
- Trying to remove a schema using
unset($openapi->components->schemas['foo']);
Give an error: "PHP Notice: Indirect modification of overloaded property cebe\openapi\spec\Components::$schemas has no effect"
- Trying to delete an element from x-Webhooks gives the same kind of error
- Tags doesn't seem to be possible at all since Tag Item are added to an unindexed array...

I am considering forking the project and starting to work on fixes for that but before I do I'd like to know:
1- If I'm doing something wrong and it's already possible to remove object. If so, I would appreciate a pointer.
2- If it's not possible, would you consider to improve the library to include the new functionality ? Or are you considering this as irrelevant to the project ? I'd be willing to help if you do.

If we can find a way to remove elements, I would also implement a function to remove unused elements automatically using a recursive referencing counter algorithm detecting unused elements.

Thanks in advance

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.