question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support @Schema(hidden = true) on @Parameter

See original GitHub issue

It would be nice to just set @Parameter(schema = @Schema(hidden = true)) to hide the Schema objects entirely.

Currently, the following still results in schema generation:

@PostMapping("/examplePost")
@Operation(summary = "schema example")
public Object example(@Parameter(schema = @Schema(hidden = true)) JsonNode json)) {
	
}

@GetMapping("/example")
public void test(@Parameter(schema = @Schema(hidden = true) JsonNode json) {

}

Results in:

"/example": {
  "post": {
	"requestBody":{
	   "content":{
	      "*/*":{
		 "schema":{
		    "$ref":"#/components/schemas/JsonNode"
		 }
	      }
	   },
	   "required":false
        }
  }
}
....

   "JsonNode":{
      "type":"object",
      "properties":{
         "float":{
            "type":"boolean"
         },
         "array":{
            "type":"boolean"
         },
         "null":{
            "type":"boolean"
         },
         "number":{
            "type":"boolean"
         },
         "floatingPointNumber":{
            "type":"boolean"
         },
         "containerNode":{
            "type":"boolean"
         },
         "missingNode":{
            "type":"boolean"
         },
         "object":{
            "type":"boolean"
         },
         "nodeType":{
            "type":"string",
            "enum":[
               "ARRAY",
               "BINARY",
               "BOOLEAN",
               "MISSING",
               "NULL",
               "NUMBER",
               "OBJECT",
               "POJO",
               "STRING"
            ]
         },
         "pojo":{
            "type":"boolean"
         },
         "integralNumber":{
            "type":"boolean"
         },
         "short":{
            "type":"boolean"
         },
         "int":{
            "type":"boolean"
         },
         "long":{
            "type":"boolean"
         },
         "double":{
            "type":"boolean"
         },
         "bigDecimal":{
            "type":"boolean"
         },
         "bigInteger":{
            "type":"boolean"
         },
         "textual":{
            "type":"boolean"
         },
         "boolean":{
            "type":"boolean"
         },
         "binary":{
            "type":"boolean"
         },
         "valueNode":{
            "type":"boolean"
         }
      }
   }

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9

github_iconTop GitHub Comments

2reactions
springdoccommented, Nov 17, 2019

Hi,

The fix will be available on v1.2.7, of springdoc-openapi.

0reactions
membersoundcommented, Nov 14, 2019

Sorry, I forgot to update the GET endpoint. Here is the example I’d expect by applying @Parameter(schema = @Schema(hidden = true) to the method parameters:

{
   "openapi":"3.0.1",
   "info": {
    "title": "example",
    "version": "1.0.0"
   },
   "paths":{
      "/test":{
         "get":{
            "operationId":"test",
            "parameters":[
               {
                  "name":"json",
                  "in":"query",
                  "required":true,
                  "schema":{ }
               }
            ],

            "responses":{
               "200":{
                  "description":"default response"
               }
            }
         }
      },
      "/testPost":{
         "post":{
            "operationId":"testPost",
            "requestBody":{
               "content":{
                  "*/*":{
                     "schema":{ }
                  }
               }
            },
            "responses":{
               "200":{
                  "description":"default response"
               }
            }
         }
      }
   },
   "components":{
      "schemas": { }
   }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Hidden parameter in springdoc-openapi doesn't work
I have annotated parameter in operation like this. parameters = { @Parameter( hidden = true, schema = @Schema(implementation = Boolean.class), ...
Read more >
Describing Parameters - Swagger
Query parameters only support primitive types. You can have an array ... Also, remember to add required: true , because path parameters are...
Read more >
Hide a Request Field in Swagger API - Baeldung
A quick and practical guide to hiding a request field in Swagger UI.
Read more >
F.A.Q - Springdoc-openapi
To enable the support of multiple OpenAPI definitions, a bean of type GroupedOpenApi ... A solution workaround would be to use: @Parameter(hidden =...
Read more >
Guide - 7.10.12.2 Migrating to OpenApi 3.0 and Swagger 2.X ...
@APIModelProperty(readOnly = true), @Schema(accessMode=AccessMode.READ_ONLY) ... @Override public Response get(@Parameter(description = "The external id") ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found