Closed akuchcik closed 1 month ago
Not reproducible. Feel free to provide a Minimal, Reproducible Example - with HelloController that reproduces the problem.
This ticket will be closed, but can be reopened if your provide the reproducible sample.
I found out that the reason for this is the "=" (equals sign) in the path. This path works: /data/logging-status/broker/{broker-identifier}: but this path doesn't work: /data/logging-status/broker={broker-identifier}:
Is this enough to reproduce the problem? I uploaded my file as .txt because github doesn't support .yaml files. test.txt
@bnasslahsen could you please look into this again? Thank you.
@akuchcik,
Try providing the github link to a Minimal, Reproducible Example - with HelloController that reproduces the problem.
@bnasslahsen to reproduce you have to use a custom yaml file in your application which should be available in the class path like this:
@Path("/openapi")
public class OpenApiDocService {
@GET
@Path("/test")
@Produces("text/yaml")
public Response getOpenApiFile() throws IOException {
String filePath = "openapi.yaml";
ClassPathResource classPathResource = new ClassPathResource(filePath);
if (classPathResource.exists()) {
InputStream inputStream = classPathResource.getInputStream();
// Return the YAML content directly
return Response.ok(StreamUtils.copyToString(inputStream, StandardCharsets.UTF_8)).build();
} else {
// File not found, return HTTP 404 Not Found
return Response.status(Response.Status.NOT_FOUND).build();
}
}
}
with a custom swagger config which will be included in a spring boot application like this:
@Configuration
public class CustomSwaggerConfig {
@Bean
public SwaggerWelcomeWebMvc swaggerWelcome(SwaggerUiConfigProperties swaggerUiConfig,
SpringDocConfigProperties springDocConfigProperties,
SwaggerUiConfigParameters swaggerUiConfigParameters,
SpringWebProvider springWebProvider) {
swaggerUiConfig.setUrl("/openapi/test");
swaggerUiConfigParameters.setShowExtensions(true);
return new SwaggerWelcomeWebMvc(swaggerUiConfig, springDocConfigProperties,
swaggerUiConfigParameters, springWebProvider);
}
}
here is the yaml file and I quote my previous comment: "I found out that the reason for this is the "=" (equals sign) in the path. This path works: /data/logging-status/broker/{broker-identifier}: but this path doesn't work as the provided parameter is ignored as you can see in the picture that I provided earlier: /data/logging-status/broker={broker-identifier}:":
openapi: 3.0.2
info:
title: Swagger Petstore - OpenAPI 3.0
version: 1.0.19
servers:
- url: /rests
paths:
/pet/{petId}:
get:
tags:
- pet
parameters:
- name: petId
in: path
description: ID of pet to return
required: true
schema:
type: string
responses:
"200":
description: successful operation
content:
application/xml:
schema:
$ref: '#/components/schemas/Pet'
application/json:
schema:
$ref: '#/components/schemas/Pet'
"400":
description: Invalid ID supplied
"404":
description: Pet not found
"/data/logging-status/broker={broker-identifier}":
get:
tags:
- logging
parameters:
- name: broker-identifier
in: path
description: Id of broker
required: true
schema:
type: string
responses:
"200":
description: successful operation
content:
application/xml:
schema:
$ref: '#/components/schemas/Pet'
application/json:
schema:
$ref: '#/components/schemas/Pet'
"400":
description: Invalid ID supplied
"404":
description: Pet not found
components:
schemas:
Category:
type: object
properties:
id:
type: integer
format: int64
example: 1
name:
type: string
example: Dogs
xml:
name: category
Tag:
type: object
properties:
id:
type: integer
format: int64
name:
type: string
xml:
name: tag
Pet:
required:
- name
- photoUrls
type: object
properties:
id:
type: integer
format: int64
example: 10
name:
type: string
example: doggie
category:
$ref: '#/components/schemas/Category'
photoUrls:
type: array
xml:
wrapped: true
items:
type: string
xml:
name: photoUrl
tags:
type: array
xml:
wrapped: true
items:
$ref: '#/components/schemas/Tag'
status:
type: string
description: pet status in the store
enum:
- available
- pending
- sold
xml:
name: pet
securitySchemes:
basicAuth:
type: http
scheme: basic
It seems that your controllers do not follow typical Spring coding conventions. As mentioned earlier, could you please upload all of your code to a public GitHub repository for further review? Otherwise, we may need to pause this conversation.
I created a new spring boot application with minimal requirements https://github.com/akuchcik/springdoc-url-parameter-bug :
@bnasslahsen I hope this is enough to replicate this issue.
@Jelicho,
Your expected behavior is invalid.
You are declaringbroker-identifier
as path variable, whereas it should be declared as query parameter.
NOTE: OpenAPI defines a unique operation as a combination of a path and an HTTP method:
@bnasslahsen if I define it as query the resulted url looks like this: "http://localhost:8080/data/logging-status/broker={broker-identifier}?broker-identifier=test"
It just add a query at the end of the url. I am not using a query as I'm not using "?" after the path. I am specifying an entry in a list.
This describing of entries/keys in a list of elements is defined in RESTCONF Protocol - RFC 8040. When using docker image swaggerapi/swagger-ui it is working as expected.
@bnasslahsen Did you get a chance to look at my last comments?
To Reproduce Issue occurs when using springdoc-openapi-starter-webmvc-ui with custom yaml file Using the same file with docker image swaggerapi/swagger-ui doesn't result with this issue and works as expected