apiaryio / api-blueprint

API Blueprint
https://apiblueprint.org
MIT License
8.65k stars 2.14k forks source link

Proposal: ability to remove fields in data structures #420

Open v1adko opened 6 years ago

v1adko commented 6 years ago

I think it would be beneficial in terms of structure reusability if there was a way to remove keys from schemas (data structures).

I'm defining request/response objects like data structures

## Model-create-request (object)
<!-- include(./create.md) -->

## Model-create-response (object)
<!-- include(./create-response.md) -->

And in files I have something like this:

base.md

a: 1 (number, required) - One
b: 2 (number, required) - Two

create.md

<!-- include(./base.md) -->
c: 3 (number, required) - Three
d: 4 (number, required) - Four

create-response.md

<!-- include(./create.md) -->
extra: extra (string, required) - Something extra
-d

So now I would expect to have a response object like this:

{
   a: 1,
   b: 2,
   c: 3,
   extra: "Extra"
}

However I have found no way to remove an object key that was already defined somewhere "on top". You can overwrite d to other value (null, undefined), but not remove it completely.

Currently -d results in

d: ""

Thank you for consideration. BTW - great work, I really enjoy using this standard!