-
-
Notifications
You must be signed in to change notification settings - Fork 504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Swagger doesn't work after custom annotation replacing request parameters #2752
Labels
enhancement
New feature or request
Comments
After adjusting your custom annotaiton: @Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
@Parameter(
schema = @Schema(type = "string", maxLength = 16, minLength = 2, pattern = "\\w+([-.]?\\w+)*"),
examples = {
@ExampleObject(name = "ar-ae"),
@ExampleObject(name = "bg-bg"),
@ExampleObject(name = "cs-cz"),
@ExampleObject(name = "de-de"),
@ExampleObject(name = "el-gr"),
@ExampleObject(name = "en-us.src"),
@ExampleObject(name = "hu-hu"),
@ExampleObject(name = "pl-pl"),
@ExampleObject(name = "ro-ro"),
@ExampleObject(name = "sk-sk")
}
)
@Size(min = 2, max = 16)
@Pattern(regexp = "\\w+([-.]?\\w+)*")
@interface LocaleParam {} This is the resulting spec, : openapi: 3.0.1
info:
title: OpenAPI definition
version: v0
servers:
- url: http://localhost:8080
description: Generated server url
paths:
/:
get:
tags:
- x-controller
operationId: manualTranslationUpdateRun
parameters:
- name: locale
in: query
required: true
schema:
maxLength: 16
minLength: 2
pattern: \w+([-.]?\w+)*
type: string
examples:
el-gr:
description: el-gr
pl-pl:
description: pl-pl
de-de:
description: de-de
hu-hu:
description: hu-hu
en-us.src:
description: en-us.src
ro-ro:
description: ro-ro
sk-sk:
description: sk-sk
bg-bg:
description: bg-bg
ar-ae:
description: ar-ae
cs-cz:
description: cs-cz
responses:
'200':
description: OK
content:
'*/*':
schema:
type: object
components: {} Examples are showing in the OpenAPI spec. |
bnasslahsen
added a commit
that referenced
this issue
Oct 8, 2024
bnasslahsen
added a commit
that referenced
this issue
Oct 8, 2024
that worked, thank you 🙏 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
I wrapped swagger annotations in a custom annotation to get rid of code duplication. However, I lost the ability of wrapped annotations on swagger page. I should be able to define custom annotations and use them?
To Reproduce
Steps to reproduce the behavior:
I have a controller like this:
Because I use the same parameter
locale
and their swagger configurations in other endpoints as well, it causes code duplication.My solution was to have custom annotations for it:
And then my controller looked like this:
Expected behavior
I expected to see requested param configurations previously defined explicitly to stay when moved to a wrapper annotation. I cannot see example options on swagger documentation when I run the new code.
Additional context
The text was updated successfully, but these errors were encountered: