Skip to content

Conversation

@chameleon82
Copy link
Contributor

@chameleon82 chameleon82 commented Sep 19, 2021

This is follow up #10166 PR to fix generation of Array[Byte] type for the case:

   properties:
        byteStringpProperty:
          type: string
          format: byte

Ref https://swagger.io/docs/specification/data-models/data-types/

The root of cause is defined default as primitive type ByteArray with type mapping from ByteArray to Array[Byte] will be obfuscated to Array[Byte] when toModelName applied.

Proposed solution: do not apply toModelName for explicit language mappings.

Other possible solutions:

  • return Array[Byte] on getTypeDeclaration. Has disadvantage as string/byte openapi type is not ArraySchema and wrapper type need to be calculated within internal type. As on lower level that conversion already leads to ByteArray which can be solved with more flexible explicit typeMapping that solution looks not clean.

Related to: 75c0180#diff-15459547d6435da71e0b630591c8e81793affb8c8152b51fbb014b3e2bec4a55R98

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master (5.3.0), 6.0.x
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@clasnake (2017/07), @jimschubert (2017/09) ❤️, @shijinkui (2018/01), @ramzimaalej (2018/03), @chameleon82 (2020/03), @Bouillie (2020/04)

@wing328
Copy link
Member

wing328 commented Sep 19, 2021

@chameleon82 thanks for the PR. Please merge the latest master into your branch when you've time (as some samples have already been updated in the master)

@wing328
Copy link
Member

wing328 commented Sep 20, 2021

cc @bgong-mdsol as well.

@wing328
Copy link
Member

wing328 commented Sep 21, 2021

Tested with the following provided in another PR/issue and the result is good (no change to the output):

openapi: 3.0.3
info:
  title: byte-string
  version: '1.0'
paths:
  /state:
    get:
      operationId: getReports
      responses:
        '200':
          description: get Report
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Reports'
components:
  schemas:
    Reports:
      properties:
        name:
          type: string
        traces:
          items:
          $ref: '#/components/schemas/TraceWithScreenshotData'
          type: array
    TraceWithScreenshotData:
      properties:
        screenshot:
          format: byte
          type: string
      type: object

@wing328 wing328 merged commit ef0186c into OpenAPITools:master Sep 21, 2021
@bgong-mdsol
Copy link
Contributor

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants