cebe / cebe/php-openapi

Missing functions to remove elements ?

未关闭
#153 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
enhancement
主要语言
PHP
星标
500
派生
99
PR 合并指标
30 天内没有已合并 PR

描述

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

贡献指南

这个仓库没有索引到贡献指南

调研方向

从现有的 paths->removePath('/path') 和 operation-unset 示例开始,然后检查 Components::$schemas、x-Webhooks 和 tags 的表示方式。重现重载属性通知,并确定如何移除每个元素;当 schemas、webhooks 和 tags 都可以无错误地移除时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
php
领域
api
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
需要澄清
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。