0

It is possible to add a pattern to a header parameter? I am putting patterns to some fields in an JAVA application using swagger OpenAPI in the YAML file. In the body fields, i was able to put some patterns with no problem at all. I also tried to find any help or guide to add a pattern in a header parameter but I didn't found it. It is possible to do this with swagger OpenAPI?

  MeuHeader:
  name: meuHeader
  in: header
  description: Header.
  schema:
    type: string
    pattern: '^[\d]{1,50}$'

The image above shows how I tried to add the pattern to the header parameter, but any string is been accepted in it. The strange fact is that in the swagger editor the pattern seems to work just fine, can someone know what the problem could be?

Borsoi
  • 1
  • 3
  • 1
    Welcome to Stack Overflow. Please take the [tour](https://stackoverflow.com/tour) to learn how Stack Overflow works and read [How to Ask](https://stackoverflow.com/help/how-to-ask) or how to improve the quality of your question. Then edit your question to include your full source code you have instead of screenshots as a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example), which can be compiled and tested by others. Currently that pattern is not as you really want, I think. – zforgo Apr 04 '23 at 21:49
  • Please provide enough code so others can better understand or reproduce the problem. – Community Apr 05 '23 at 15:56

0 Answers0