Problem/Motivation

Currently, the Commerce API module swaps the JsonApiGenerator (See \Drupal\commerce_api\Plugin\openapi\OpenApiGenerator\AdjustedJsonApiGenerator), and basically filters out the JSON API routes provided by the Commerce API module.

The reason for that is that our resource types are incorrect.

@mglaman: Can't we update our resource type repository (i.e RenamableResourceTypeRepository) to provide resource types for our routes so that the resource type upcasting works? We should be able to do that no? By specifying the entity type ID both for the entity type and the bundle.

I've also noticed we currently have the following code:

$routes->addDefaults([JsonapiRoutes::RESOURCE_TYPE_KEY => 'orders--virtual']);

For example, the cart add, cart remove/update items routes actually return order items... Shouldn't we fix that? Same thing with the coupons resources.

Comments

jsacksick created an issue. See original summary.

anybody’s picture

Title: Open API support » OpenAPI support

Yes indeed very sad. OpenAPI is super helpful for developers using the API, but currently doesn't work correctly in combination with commerce_api or jsonapi_extras

I there's a clear plan how to fix that correctly, we'd like to help getting things done! :)

jsacksick’s picture

I there's a clear plan how to fix that correctly, we'd like to help getting things done! :)

Nope, this is sad indeed... Haven't looked into it recently, but the last time I did (probably years ago already) it seemed quite complicated to fix lol.
Also the OpenAPI module itself seems minimally maintained...

bradjones1’s picture

(New) OpenAPI maintainer here.

Schema generation will be much easier in core (and hopefully also contrib) once #3031367: Generate JSON schema for content entity types goes in. I have opened new major versions for OpenAPI and also OpenAPI for JSON:API so you can take a look at what's going on there. I'd be happy to 1) have some help getting all that over the finish line and 2) talk about how we could integrate this in to Commerce since I have a lot of history in this space as well.