A platform for community discussion. Free, open, simple.
DEV: Update api docs spec for invite enpoint (#34843)
Blake Erickson0f91ce6079de
diff --git a/spec/requests/api/invites_spec.rb b/spec/requests/api/invites_spec.rbindex 28442dbcb74..9579b1bc4d2 100644--- a/spec/requests/api/invites_spec.rb+++ b/spec/requests/api/invites_spec.rb@@ -12,110 +12,19 @@ RSpec.describe "invites" doconsumes "application/json"parameter name: "Api-Key", in: :header, type: :string, required: trueparameter name: "Api-Username", in: :header, type: :string, required: true-- parameter name: :request_body,- in: :body,- schema: {- type: :object,- properties: {- email: {- type: :string,- example: "[email protected]",- description: "required for email invites only",- },- skip_email: {- type: :boolean,- default: false,- },- custom_message: {- type: :string,- description: "optional, for email invites",- },- max_redemptions_allowed: {- type: :integer,- example: 5,- default: 1,- description: "optional, for link invites",- },- topic_id: {- type: :integer,- },- group_ids: {- type: :string,- description:- "Optional, either this or `group_names`. Comma separated list for multiple ids.",- example: "42,43",- },- group_names: {- type: :string,- description:- "Optional, either this or `group_ids`. Comma separated list for multiple names.",- example: "foo,bar",- },- expires_at: {- type: :string,- description:- "optional, if not supplied, the invite_expiry_days site setting is used",- },- },- }+ expected_request_schema = load_spec_schema("invite_create_request")+ parameter name: :params, in: :body, schema: expected_request_schemaproduces "application/json"response "200", "success response" do- schema type: :object,- properties: {- id: {- type: :integer,- example: 42,- },- link: {- type: :string,- example: "http://example.com/invites/9045fd767efe201ca60c6658bcf14158",- },- email: {- type: :string,- example: "[email protected]",- },- emailed: {- type: :boolean,- example: false,- },- custom_message: {- type: %i[string null],- example: "Hello world!",- },- topics: {- type: :array,- items: {- },- example: [],- },- groups: {- type: :array,- items: {- },- example: [],- },- created_at: {- type: :string,- example: "2021-01-01T12:00:00.000Z",- },- updated_at: {- type: :string,- example: "2021-01-01T12:00:00.000Z",- },- expires_at: {- type: :string,- example: "2021-02-01T12:00:00.000Z",- },- expired: {- type: :boolean,- example: false,- },- }+ expected_response_schema = load_spec_schema("invite_create_response")+ schema expected_response_schema- let(:request_body) { { email: "[email protected]" } }- run_test!+ let(:params) { { email: "[email protected]" } }+ it_behaves_like "a JSON endpoint", 200 do+ let(:expected_response_schema) { expected_response_schema }+ let(:expected_request_schema) { expected_request_schema }+ endendendenddiff --git a/spec/requests/api/schemas/json/invite_create_request.json b/spec/requests/api/schemas/json/invite_create_request.jsonnew file mode 100644index 00000000000..ee5fa82c911--- /dev/null+++ b/spec/requests/api/schemas/json/invite_create_request.json@@ -0,0 +1,42 @@+{+ "type": "object",+ "additionalProperties": false,+ "properties": {+ "email": {+ "type": "string",+ "example": "[email protected]",+ "description": "required for email invites only"+ },+ "skip_email": {+ "type": "boolean",+ "default": false+ },+ "custom_message": {+ "type": "string",+ "description": "optional, for email invites"+ },+ "max_redemptions_allowed": {+ "type": "integer",+ "example": 5,+ "default": 1,+ "description": "optional, for link invites"+ },+ "topic_id": {+ "type": "integer"+ },+ "group_ids": {+ "type": "string",+ "description": "Optional, either this or `group_names`. Comma separated list for multiple ids.",+ "example": "42,43"+ },+ "group_names": {+ "type": "string",+ "description": "Optional, either this or `group_ids`. Comma separated list for multiple names.",+ "example": "foo,bar"+ },+ "expires_at": {+ "type": "string",+ "description": "optional, if not supplied, the invite_expiry_days site setting is used"+ }+ }+}diff --git a/spec/requests/api/schemas/json/invite_create_response.json b/spec/requests/api/schemas/json/invite_create_response.jsonnew file mode 100644index 00000000000..26914b77d05--- /dev/null+++ b/spec/requests/api/schemas/json/invite_create_response.json@@ -0,0 +1,94 @@+{+ "type": "object",+ "additionalProperties": false,+ "properties": {+ "id": {+ "type": "integer",+ "example": 42+ },+ "invite_key": {+ "type": "string"+ },+ "link": {+ "type": "string",+ "example": "http://example.com/invites/9045fd767efe201ca60c6658bcf14158"+ },+ "description": {+ "type": [+ "string",+ "null"+ ]+ },+ "email": {+ "type": "string",+ "example": "[email protected]"+ },+ "domain": {+ "type": [+ "string",+ "null"+ ]+ },+ "emailed": {+ "type": "boolean",+ "example": false+ },+ "can_delete_invite": {+ "type": "boolean"+ },+ "custom_message": {+ "type": [+ "string",+ "null"+ ],+ "example": "Hello world!"+ },+ "created_at": {+ "type": "string",+ "example": "2021-01-01T12:00:00.000Z"+ },+ "updated_at": {+ "type": "string",+ "example": "2021-01-01T12:00:00.000Z"+ },+ "expires_at": {+ "type": "string",+ "example": "2021-02-01T12:00:00.000Z"+ },+ "expired": {+ "type": "boolean",+ "example": false+ },+ "topics": {+ "type": "array",+ "items": {+ "type": "object"+ },+ "example": []+ },+ "groups": {+ "type": "array",+ "items": {+ "type": "object"+ },+ "example": []+ }+ },+ "required": [+ "id",+ "invite_key",+ "link",+ "description",+ "email",+ "domain",+ "emailed",+ "can_delete_invite",+ "custom_message",+ "created_at",+ "updated_at",+ "expires_at",+ "expired",+ "topics",+ "groups"+ ]+}