jskov / openapi-jaxrs-client

An OpenAPI JAX-RS client code generator
Apache License 2.0
1 stars 4 forks source link

default-schema response should be mapped to responses without schema #466

Closed jskov-jyskebank-dk closed 10 months ago

jskov-jyskebank-dk commented 1 year ago

See https://swagger.io/specification/#responses-object

The ACR api declares a 200 response without type (schema), which causes generator to insist on parser-fixup-void-200-to-204. It should instead use the provided default-schema.

{
  "swagger": "2.0",
  "info": {
    "title": "Azure Container Registry",
    "description": "Metadata API definition for the Azure Container Registry runtime",
    "version": "2019-08-15-preview"
  },
...
  "paths": {
    "/v2/": {
      "get": {
        "tags": [
          "v2"
        ],
        "description": "Tells whether this Docker Registry instance supports Docker Registry HTTP API v2",
        "operationId": "V2Support_Check",
        "x-ms-examples": {
          "Check Docker Registry V2 Support": {
            "$ref": "./examples/GetDockerRegistryV2Support.json"
          }
        },
        "responses": {
          "200": {
            "description": "Successful response. API v2 supported"
          },
          "default": {
            "description": "ACR error response describing why the operation failed.",
            "schema": {
              "$ref": "#/definitions/AcrErrors"
            }
          }
        }
      }
    },
jskov-jyskebank-dk commented 1 year ago

Related from the Nexus API:

  /v1/status:
    get:
      tags:
      - "Status"
      summary: "Health check endpoint that validates server can respond to read requests"
      description: ""
      operationId: "isAvailable"
      consumes:
      - "application/json"
      produces:
      - "application/json"
      parameters: []
      responses:
        "200":
          description: "Available to service requests"
        "503":
          description: "Unavailable to service requests"

Generator would insist on 200-to-204.

But the call does return 200, so the generator should make such an assumption. Use the API's return type, but then just mark it as void.