Skip to content

Path parameters are being output to the openapi.json as query params #595

Closed
@creedasaurus

Description

@creedasaurus

We've been toying with using Helidon SE for developing some new services, however we take a fairly strict dependency on OpenAPI specs (for better or worse). After the compile phase I copy the generated openapi.json out to a project directory to be "vendored" and referenced for things like client generation and whatnot.

What I found is that the openapi generator actually throws validation errors when using the Avaje HTTP generated openapi.json like the following:

> There were issues with the specification. The option can be disabled via validateSpec (Maven/Gradle) or --skip-validate-spec (CLI).
   | Error count: 6, Warning count: 0
  Errors:
        -paths.'/api/v2/{depId}/definitions/achievement'. Declared path parameter depId needs to be defined as a path parameter in path or operation level
...

Looking a little closer, I found that it was indeed outputting the path parameters as query params. Like the following example:

@Get("/find/{type}")
List<Contact> findByType(String type, @QueryParam String lastName) {
    // ...
}

The expected openapi spec should specify type as a path parameter, and lastName as a query parameter.

But it outputs:

"/contacts/find/{type}" : {
	"get" : {
		"tags" : [
			
		],
		"summary" : "",
		"description" : "",
		"parameters" : [
			{
				"name" : "type",
				"in" : "query", <------- should be path
				"schema" : {
					"type" : "string"
				}
			},
			{
				"name" : "lastName",
				"in" : "query",
				"schema" : {
					"type" : "string"
				}
			}
		],

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions