diff --git a/app/models/graphiti/open_api/endpoint.rb b/app/models/graphiti/open_api/endpoint.rb index b951f0f..16c4653 100644 --- a/app/models/graphiti/open_api/endpoint.rb +++ b/app/models/graphiti/open_api/endpoint.rb @@ -25,10 +25,10 @@ def paths { path => { parameters: parameters, - }.merge(collection_actions.map(&:operation).inject(&:merge)), + }.merge(collection_actions.map(&:operation).inject({}, &:merge)), resource_path => { parameters: [{'$ref': "#/components/parameters/#{resource.type}_id"}] + parameters, - }.merge(resource_actions.map(&:operation).inject(&:merge)), + }.merge(resource_actions.map(&:operation).inject({}, &:merge)), } end @@ -52,7 +52,7 @@ def parameters end def resource - resource_actions.first.resource + actions.first.resource end def_instance_delegators :resource, :type diff --git a/spec/fixtures/files/schema_basic.json b/spec/fixtures/files/schema_basic.json index af918e3..a48e8c0 100644 --- a/spec/fixtures/files/schema_basic.json +++ b/spec/fixtures/files/schema_basic.json @@ -67,6 +67,124 @@ "count" ] } + }, + { + "name": "CreateOnlyResource", + "type": "create_only_entities", + "graphql_entrypoint": "createOnlyEntities", + "description": "Resource supporting only the create action.", + "attributes": { + "id": { + "type": "integer_id", + "readable": true, + "writable": true, + "description": null + }, + "label": { + "type": "string", + "readable": true, + "writable": true, + "description": null + } + }, + "extra_attributes": {}, + "sorts": { + "id": {}, + "label": {} + }, + "filters": { + "id": { + "type": "integer_id", + "operators": [ + "eq", + "not_eq", + "gt", + "gte", + "lt", + "lte" + ] + }, + "label": { + "type": "string", + "operators": [ + "eq", + "not_eq", + "eql", + "not_eql", + "prefix", + "not_prefix", + "suffix", + "not_suffix", + "match", + "not_match" + ] + } + }, + "relationships": {}, + "stats": { + "total": [ + "count" + ] + } + }, + { + "name": "ShowOnlyResource", + "type": "show_only_entities", + "graphql_entrypoint": "showOnlyEntities", + "description": "Resource supporting only the show action.", + "attributes": { + "id": { + "type": "integer_id", + "readable": true, + "writable": true, + "description": null + }, + "label": { + "type": "string", + "readable": true, + "writable": true, + "description": null + } + }, + "extra_attributes": {}, + "sorts": { + "id": {}, + "label": {} + }, + "filters": { + "id": { + "type": "integer_id", + "operators": [ + "eq", + "not_eq", + "gt", + "gte", + "lt", + "lte" + ] + }, + "label": { + "type": "string", + "operators": [ + "eq", + "not_eq", + "eql", + "not_eql", + "prefix", + "not_prefix", + "suffix", + "not_suffix", + "match", + "not_match" + ] + } + }, + "relationships": {}, + "stats": { + "total": [ + "count" + ] + } } ], "endpoints": { @@ -79,6 +197,20 @@ "resource": "EntityResource" } } + }, + "/api/v1/create_only_entities": { + "actions": { + "create": { + "resource": "CreateOnlyResource" + } + } + }, + "/api/v1/show_only_entities": { + "actions": { + "show": { + "resource": "ShowOnlyResource" + } + } } }, "types": {