Skip to content

API spec with mime type application/vnd.xxx #105

Closed
@schoettl

Description

@schoettl

Another question: The Xentral ERP OpenAPI spec declares custom mime types like application/vnd.xxx+json.


        "operationId": "product.view",
        "summary": "View product",
        "description": "Returns details of a single product",
        "responses": {
          "200": {
            "description": "Operation completed successfully.",
            "content": {
              "application/vnd.xentral.default.v1+json": {

yields

data Product'viewResponse =
   Product'viewResponseError GHC.Base.String -- ^ Means either no matching case available or a parse error
  | Product'viewResponse200 -- ^ Operation completed successfully.
  | Product'viewResponse400 -- ^ IETF RFC 7807 Problem API compliant response
  

with no actual response data type.

The custom vendor mime types seem to be generally OK but seem to be unsupported by this generator. It might make sense to change the parser to handle regex application/(vnd\.[\a\d]+\+)?json as JSON.

I just did search & replace with application/json, then types were generated.

The next problem is that the Xentral API server requires the exact mime type specified in their spec and it does not respond to requests with Accept: application/json. I think it's not a good design decision by Xentral. But this maybe should be considered when implementing support vendor mime types in this generator.

I now have to work around this... my plan is to use this config:

  let config = Configuration { configBaseURL = "https://xxx.xentral.biz"
                             , configSecurityScheme = addXentralAuthHeader "xxxx" . HS.addRequestHeader "Accept" "application/vnd.xentral.default.v1+json"
                             , configIncludeUserAgent = False
                             , configApplicationName = "xxx"
                             }

Though, even worse, Xentral declares different vendor mime types so I need to generate a map for looking up the specific mime type for each operation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions