File tree 2 files changed +19
-11
lines changed
2 files changed +19
-11
lines changed Original file line number Diff line number Diff line change @@ -736,18 +736,23 @@ func (s *Schema) fromOpenAPISchema() (schema schemaJSON) {
736
736
schema ["enum" ] = sEnum
737
737
}
738
738
739
- if sFormat := s .Format ; sFormat != "" {
740
- schema ["format" ] = sFormat
741
- }
742
739
if sMinLength := s .MinLength ; sMinLength != 0 {
743
740
schema ["minLength" ] = sMinLength
744
741
}
745
742
if sMaxLength := s .MaxLength ; nil != sMaxLength {
746
743
schema ["maxLength" ] = * sMaxLength
747
744
}
745
+
746
+ if sFormat := s .Format ; sFormat != "" {
747
+ schema ["format" ] = sFormat
748
+ }
748
749
if sPattern := s .Pattern ; sPattern != "" {
749
750
schema ["pattern" ] = sPattern
750
751
}
752
+ if s .Format == "byte" {
753
+ // Matches base64 (RFC 4648) `standard` base64 not `base64url`.
754
+ schema ["pattern" ] = "^[\\ w\\ d+\\ /=]*$"
755
+ }
751
756
752
757
if nil != s .Min {
753
758
schema ["minimum" ] = * s .Min
@@ -845,6 +850,9 @@ func (s *Schema) fromOpenAPISchema() (schema schemaJSON) {
845
850
}
846
851
847
852
schema ["$schema" ] = "http://json-schema.org/draft-04/schema#"
853
+ //FIXME
854
+ //https://github.com/openapi-contrib/openapi-schema-to-json-schema/blob/45c080c38027c30652263b4cc44cd3534f5ccc1b/lib/converters/schema.js
855
+ //https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#schemaObject
848
856
return
849
857
}
850
858
Original file line number Diff line number Diff line change @@ -311,7 +311,7 @@ var schemaExamples = []schemaExample{
311
311
},
312
312
313
313
{
314
- Title : " STRING: format 'date-time'" ,
314
+ Title : ` STRING: format "byte"` ,
315
315
Schema : NewBytesSchema (),
316
316
Serialization : map [string ]interface {}{
317
317
"type" : "string" ,
@@ -326,13 +326,13 @@ var schemaExamples = []schemaExample{
326
326
}
327
327
return data
328
328
}()),
329
- base64 .URLEncoding .EncodeToString (func () []byte {
330
- data := make ([]byte , 0 , 1024 )
331
- for i := 0 ; i < cap (data ); i ++ {
332
- data = append (data , byte (i ))
333
- }
334
- return data
335
- }()),
329
+ // base64.URLEncoding.EncodeToString(func() []byte {
330
+ // data := make([]byte, 0, 1024)
331
+ // for i := 0; i < cap(data); i++ {
332
+ // data = append(data, byte(i))
333
+ // }
334
+ // return data
335
+ // }()),
336
336
},
337
337
AllInvalid : []interface {}{
338
338
nil ,
You can’t perform that action at this time.
0 commit comments