github.com/khulnasoft/codebase@v0.0.0-20231214144635-a707781cbb24/go-bitbucket/README.md (about)

     1  # Bitbucket OpenAPI
     2  
     3  This is trimmed version of generated bitbucket OpenAPI client, which
     4  **contains [Reports API](https://developer.atlassian.com/bitbucket/api/2/reference/search?q=tag:reports) only**
     5  which is needed to use the [Code Insights](https://support.atlassian.com/bitbucket-cloud/docs/code-insights/) feature for [khulnasoft/codebase](https://github.com/khulnasoft/codebase).
     6  
     7  Bitbucket API swagger definitions can be found here [Bitbucket API](https://developer.atlassian.com/bitbucket/api/2/reference/meta/serialization#oai).
     8  
     9  ## Problems with official OpenAPI definitions
    10  
    11  Unfortunately [officially provided OpenAPI definition](https://developer.atlassian.com/bitbucket/api/2/reference/meta/serialization#oai) is not completely valid , see this issues:
    12  
    13  1. [ktrysmt/go-bitbucket Issue #96](https://github.com/ktrysmt/go-bitbucket/issues/96)
    14  
    15  1. [JIRA Bitbucket Cloud/BCLOUD-17601 - api.bitbucket.org/swagger.json is broken](https://jira.atlassian.com/browse/BCLOUD-17601)
    16  
    17  However, we were able to generate needed models via [OpenAPI Generator CLI](https://github.com/OpenAPITools/openapi-generator-cli/) with `--skip-validate-spec` ignoring the errors.
    18  
    19  Also, to make it work, in generated code URLs `{workspace}` need to be replaced with `{username}`,
    20  because BitBucket OpenAPI definition is not correct :shrug::
    21  
    22  **Resource URL** is `/2.0/repositories/{workspace}/{repo_slug}/commit/{commit}/reports/{reportId}`
    23  
    24  but **Path actual parameters** are `username`, `repo_slug`, `commit`, `reportId`
    25  
    26  ## Attempts to generate code
    27  
    28  - Go Swagger:
    29  
    30      ```sh
    31      $ swagger validate https://bitbucket.org/api/swagger.json
    32      json: cannot unmarshal bool into Go struct field SwaggerProps.definitions of type []string
    33      ```
    34  
    35  - OpenAPI Generator CLI:
    36  
    37      ```sh
    38      $ docker run --rm -v "${PWD}:/local" \
    39          openapitools/openapi-generator-cli generate \
    40               -i https://api.bitbucket.org/swagger.json
    41               -g go \
    42               -o /local/out/go
    43      ...
    44      Exception in thread "main" org.openapitools.codegen.SpecValidationException: There were issues with the specification. The option can be disabled via validateSpec (Maven/Gradle) or --skip-validate-spec (CLI).
    45      | Error count: 53, Warning count: 17
    46      ...
    47      ```