widdershins icon indicating copy to clipboard operation
widdershins copied to clipboard

omitBody not working as described

Open galvo opened this issue 4 years ago โ€ข 5 comments

Describe the bug A clear and concise description of what the bug is. Reports containing a full reproduction recipe (command-line and input file gist) will get a much faster response.

  • [x] - I have checked that my input document is valid OpenAPI 2.0/3.0.x or AsyncAPI 1.x

To Reproduce Steps to reproduce the behavior:

When you run:

node widdershins --expandBody true https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore-expanded.yaml -o petstore.md

You get the following table output

Parameters

Name In Type Required Description
body body NewPet true Pet to add to the store
ยป name body string true none
ยป tag body string false none

But when you add --omitBody true and run the command

node widdershins --expandBody true --omitBody true https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore-expanded.yaml -o petstore.md

i expect that the table should not include the body row below but it does

Parameters

Name In Type Required Description
body body NewPet true Pet to add to the store
name body string true none
tag body string false none

Expected behavior

i expect the following table

Parameters

Name In Type Required Description
name body string true none
tag body string false none

Versions: 3.6.6

Additional context

galvo avatar Nov 21 '19 18:11 galvo

Is there a simple way to to configure expanded Body for all schemas instead of generating a Schemas section every time.. this seems to only work if the schemas are external references. Screenshot 2019-11-21 at 18 05 39

galvo avatar Nov 21 '19 18:11 galvo

--expandBody and --omitBody are (as you might be able to guess from their names / descriptions) mutually exclusive options. I might be able to make this explicit using the yargs options parser.

As to your second question, it seems like you want something like the opposite of --shallowSchemas. There's no such option at the moment.

MikeRalphson avatar Nov 26 '19 12:11 MikeRalphson

I need to check again but i think when i use --resolve for external refs then these schemas appear inline and never in the schemas section.. so its something like that behaviour.. i will try and look at creating a PR around this

galvo avatar Nov 26 '19 12:11 galvo

If you put the external $refs in /components/schemas and use internal $refs from each usage into /components/schemas you should be able to work-around this behaviour.

MikeRalphson avatar Nov 26 '19 12:11 MikeRalphson

Hello! ๐Ÿ‘‹

I'm also trying to get the same table without the body that @galvo described in the original post.

Seems like there is a work around, but I haven't been able to get it to work.

This is the expanded PetStore example I'm using but refactored into multiple files using $ref's.

๐Ÿ‘‰ petstore.zip

It seems like maybe I need to change line 48 in paths/pets.yaml to this...

   $ref: '#components/schemas/NewPet'

But that gives me ๐Ÿ‘‡ which is not what I'm looking for.

Name In Type Required Description
body body any true Pet to add to the store

Here is my environments config file ...

{
  "resolve": true,
  "expandBody": true,
  "language_tabs": [
    { "javascript": "Javascript" },
    { "javascript--nodejs": "Node.JS" },
    { "python": "Python" },
    { "go": "Go" }, { "http": "HTTP" },
    { "ruby": "Ruby" }
  ]
}

๐Ÿค” What am I missing?

timganter avatar Mar 13 '22 18:03 timganter