You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Luca Leonardo Scorcia (Jira)" <ji...@apache.org> on 2021/04/27 00:24:00 UTC

[jira] [Updated] (CXF-8530) Error in OpenAPI descriptor for byte array properties

     [ https://issues.apache.org/jira/browse/CXF-8530?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Luca Leonardo Scorcia updated CXF-8530:
---------------------------------------
    Description: 
When using OpenAPIFeature to generate the OpenAPIv3 description document for a CXF web service, the built-in type mapper generates a wrong output in the JSON document.

For repro, take the example project at [https://github.com/apache/cxf/tree/master/distribution/src/main/release/samples/jax_rs/description_openapi_v3_web] and add a byte[] property to the Item class, like in the attached patch file.

Run the project and scroll to the end of the generated json document at [http://localhost:9000/app/openapi.json]:

{{"components" : {}}
 {{  "schemas" : {}}
 {{    "Item" : {}}
 {{      "type" : "object",}}
 {{      "properties" : {}}
 {{         "name" : {}}
 {{            "type" : "string"}}
 {{         },}}
 {{         "value" : {}}
 {{            "type" : "string"}}
 {{         },}}
 {{         {color:#ff0000}"binary" : {{color}}}
 {{{color:#ff0000}           "type" : "array",{color}}}
 {{{color:#ff0000}           "items" : {{color}}}
 {{{color:#ff0000}             "type" : "string",{color}}}
 {{{color:#ff0000}             "format" : "byte"{color}}}
 {{{color:#ff0000}           }{color}}}
 {{{color:#ff0000}         }{color}}}
         }
       }
     }
 }

This is interpreted by OpenAPI codegen tools as a List of byte[].

According to the OpenAPIv3 spec, byte arrays should actually be represented as

{
     "type": "string",
     "format": "byte"
}

without the "type": "array" wrapper.

  was:
When using OpenAPIFeature to generate the OpenAPIv3 description document for a CXF web service, the built-in type mapper generates a wrong output in the JSON document.

For repro, take the example project at [https://github.com/apache/cxf/tree/master/distribution/src/main/release/samples/jax_rs/description_openapi_v3_web] and add a byte[] property to the Item class, like in the attached patch file.

Run the project and scroll to the end of the generated json document at [http://localhost:9000/app/openapi.json]:

{{"components" : {}}
{{  "schemas" : {}}
{{    "Item" : {}}
{{      "type" : "object",}}
{{      "properties" : {}}
{{         "name" : {}}
{{            "type" : "string"}}
{{         },}}
{{         "value" : {}}
{{            "type" : "string"}}
{{         },}}
{{         {color:#FF0000}"binary" : {{color}}}
{{{color:#FF0000}           "type" : "array",{color}}}
{{{color:#FF0000}           "items" : {{color}}}
{{{color:#FF0000}             "type" : "string",{color}}}
{{{color:#FF0000}             "format" : "byte"{color}}}
{{{color:#FF0000}           }{color}}}
{{{color:#FF0000}         }{color}}}
{{      }}}
{{   }}}
{{  }}}
{{ }}}

This is interpreted by OpenAPI codegen tools as a List of byte[].

According to the OpenAPIv3 spec, byte arrays should actually be represented as

{{ {}}
{{    "type": "string",}}
{{    "format": "byte"}}
{{ }}}

without the "type": "array" wrapper.


> Error in OpenAPI descriptor for byte array properties
> -----------------------------------------------------
>
>                 Key: CXF-8530
>                 URL: https://issues.apache.org/jira/browse/CXF-8530
>             Project: CXF
>          Issue Type: Bug
>    Affects Versions: 3.4.3
>            Reporter: Luca Leonardo Scorcia
>            Priority: Major
>         Attachments: repro.patch
>
>
> When using OpenAPIFeature to generate the OpenAPIv3 description document for a CXF web service, the built-in type mapper generates a wrong output in the JSON document.
> For repro, take the example project at [https://github.com/apache/cxf/tree/master/distribution/src/main/release/samples/jax_rs/description_openapi_v3_web] and add a byte[] property to the Item class, like in the attached patch file.
> Run the project and scroll to the end of the generated json document at [http://localhost:9000/app/openapi.json]:
> {{"components" : {}}
>  {{  "schemas" : {}}
>  {{    "Item" : {}}
>  {{      "type" : "object",}}
>  {{      "properties" : {}}
>  {{         "name" : {}}
>  {{            "type" : "string"}}
>  {{         },}}
>  {{         "value" : {}}
>  {{            "type" : "string"}}
>  {{         },}}
>  {{         {color:#ff0000}"binary" : {{color}}}
>  {{{color:#ff0000}           "type" : "array",{color}}}
>  {{{color:#ff0000}           "items" : {{color}}}
>  {{{color:#ff0000}             "type" : "string",{color}}}
>  {{{color:#ff0000}             "format" : "byte"{color}}}
>  {{{color:#ff0000}           }{color}}}
>  {{{color:#ff0000}         }{color}}}
>          }
>        }
>      }
>  }
> This is interpreted by OpenAPI codegen tools as a List of byte[].
> According to the OpenAPIv3 spec, byte arrays should actually be represented as
> {
>      "type": "string",
>      "format": "byte"
> }
> without the "type": "array" wrapper.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)