How to override pattern from java @Pattern validation

749 views
Skip to first unread message

alex.r...@temet.ch

unread,
Feb 4, 2017, 3:15:27 AM2/4/17
to Swagger
I have this validation:

 /**
 * @return the name
 */

 
@NotNull
 
//Validation:
 
@Pattern(regexp="(?U)\\w[\\w -]*\\w")
 
public final String getName() {
 
return name;
 
}


The @Pattern is converted to a pattern constraint in swagger, but the (?U) switch is not supported.

How can I override the pattern? I didn't see a "pattern" param in @ApiModelProperty.

In any case, I would rather override the pattern in my Rest definition than in my model definition if possible.

tony tam

unread,
Feb 4, 2017, 4:34:45 PM2/4/17
to swagger-sw...@googlegroups.com
Can you please share what is being emitted in the swagger definition?

--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

alex.r...@temet.ch

unread,
Feb 4, 2017, 5:52:54 PM2/4/17
to Swagger
Relevant part in yaml:
 
     properties:
      id
:
        type
: integer
        format
: int64
      name
:
        type
: string
        pattern
: '(?U)\w[\w -]*\w'

Results in Swagger error Object didn't pass validation for format regex: (?U)\w[\w -]*\w

If I remove the (?U) in swagger editor, the definition is accepted

tony tam

unread,
Feb 4, 2017, 5:59:15 PM2/4/17
to swagger-sw...@googlegroups.com
I think this is because of differences between Java and the REGEX format supported in the editor.  Could you please open an issue in swagger-core so we can see about converting the syntax to the spec supported one?

alex.r...@temet.ch

unread,
Feb 4, 2017, 6:08:34 PM2/4/17
to Swagger

lang...@yahoo.com

unread,
Feb 4, 2017, 8:36:02 PM2/4/17
to swagger-sw...@googlegroups.com

--------------------------------------------
On Sun, 2/5/17, alex.r...@temet.ch <alex.r...@temet.ch> wrote:

Subject: Re: How to override pattern from java @Pattern validation
To: "Swagger" <swagger-sw...@googlegroups.com>
Date: Sunday, February 5, 2017, 1:08 AM

Thanks, I
did: https://github.com/swagger-api/swagger-core/issues/2102



--

You received this message because you are subscribed to the
Google Groups "Swagger" group.

To unsubscribe from this group and stop receiving emails
from it, send an email to swagger-swaggers...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
a 24 ianuarie 1871 primul-ministru depune pe masa forului legiuitor arul afacerii Stroussberg. Este vorba despre implicatiile pe care le are in nania falimentul acestui consortiu provocat de razboiul franco-prusian. jponsabilitatea sa ca administrator central al avutiei tarii il determina deci I. Ghica sa solicite masuri legale pentru protejarea intereselor tarii.
Reply all
Reply to author
Forward
0 new messages