Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PUT and POST model overwritten #13

Open
metasection opened this issue Oct 29, 2014 · 2 comments
Open

PUT and POST model overwritten #13

metasection opened this issue Oct 29, 2014 · 2 comments

Comments

@metasection
Copy link

When you define both a server.put and server.post with the same URL, the last define is used as the model for both methods in the Swagger UI.

I would expect the HTTP verb to make these unique.

Example 1

server.put({url: '/billing/event',
  swagger: {
    summary: 'Update',
    notes: '',
    nickname: 'putBillingEvent'
  },
  validation: {
    field1: { isRequired: true, scope: 'body', description: 'Field 1' },
    field2: { isRequired: true, scope: 'body', description: 'Field 2' },
    field3: { isRequired: true, scope: 'body', description: 'Field 3' },
    field4: { isRequired: true, scope: 'body', description: 'Field 4' },
    field5: { isRequired: true, scope: 'body', description: 'Field 5' },
    field6: { isRequired: true, scope: 'body', description: 'Field 6' },
    field7: { isRequired: true, scope: 'body', description: 'Field 7' },
    field8: { isRequired: true, scope: 'body', description: 'Field 8' }
  }}, require('./api/billing_event').putBillingEvent);

server.post({url: '/billing/event',
  swagger: {
    summary: 'Save',
    notes: '',
    nickname: 'postBillingEvent'
  },
  validation: {
    field1: { isRequired: true, scope: 'body', description: 'Field 1' }
  }}, require('./api/billing_event').postBillingEvent);

screen shot 2014-10-29 at 11 19 50 am

Example 2

server.post({url: '/billing/event',
  swagger: {
    summary: 'Save',
    notes: '',
    nickname: 'postBillingEvent'
  },
  validation: {
    field1: { isRequired: true, scope: 'body', description: 'Field 1' }
  }}, require('./api/billing_event').postBillingEvent);

server.put({url: '/billing/event',
  swagger: {
    summary: 'Update',
    notes: '',
    nickname: 'putBillingEvent'
  },
  validation: {
    field1: { isRequired: true, scope: 'body', description: 'Field 1' },
    field2: { isRequired: true, scope: 'body', description: 'Field 2' },
    field3: { isRequired: true, scope: 'body', description: 'Field 3' },
    field4: { isRequired: true, scope: 'body', description: 'Field 4' },
    field5: { isRequired: true, scope: 'body', description: 'Field 5' },
    field6: { isRequired: true, scope: 'body', description: 'Field 6' },
    field7: { isRequired: true, scope: 'body', description: 'Field 7' },
    field8: { isRequired: true, scope: 'body', description: 'Field 8' }
  }}, require('./api/billing_event').putBillingEvent);

screen shot 2014-10-29 at 11 22 00 am

Here is the resources json.

  "resourcePath": "/swagger/billing",
  "apis": [
  {
    "path": "/billing/event",
    "description": "",
    "operations": [
      {
        "notes": null,
        "nickname": "postBillingEvent",
        "produces": [
          "application/json"
        ],
        "consumes": [
          "application/json"
        ],
        "responseMessages": [
          {
            "code": 500,
            "message": "Internal Server Error"
          }
        ],
        "parameters": [
          {
            "name": "Body",
            "required": true,
            "dataType": "BillingEvent",
            "paramType": "body"
          }
        ],
        "summary": "Save",
        "httpMethod": "POST",
        "method": "POST"
      },
      {
        "notes": null,
        "nickname": "putBillingEvent",
        "produces": [
          "application/json"
        ],
        "consumes": [
          "application/json"
        ],
        "responseMessages": [
          {
            "code": 500,
            "message": "Internal Server Error"
          }
        ],
        "parameters": [
          {
            "name": "Body",
            "required": true,
            "dataType": "BillingEvent",
            "paramType": "body"
          }
        ],
        "summary": "Update",
        "httpMethod": "PUT",
        "method": "PUT"
      }
    ]
  }
],
  "models": {
  "BillingEvent": {
    "properties": {
      "field1": {
        "type": "string",
          "dataType": "string",
          "name": "field1",
          "description": "Field 1",
          "required": true
      },
      "field2": {
        "type": "string",
          "dataType": "string",
          "name": "field2",
          "description": "Field 2",
          "required": true
      },
      "field3": {
        "type": "string",
          "dataType": "string",
          "name": "field3",
          "description": "Field 3",
          "required": true
      },
      "field4": {
        "type": "string",
          "dataType": "string",
          "name": "field4",
          "description": "Field 4",
          "required": true
      },
      "field5": {
        "type": "string",
          "dataType": "string",
          "name": "field5",
          "description": "Field 5",
          "required": true
      },
      "field6": {
        "type": "string",
          "dataType": "string",
          "name": "field6",
          "description": "Field 6",
          "required": true
      },
      "field7": {
        "type": "string",
          "dataType": "string",
          "name": "field7",
          "description": "Field 7",
          "required": true
      },
      "field8": {
        "type": "string",
          "dataType": "string",
          "name": "field8",
          "description": "Field 8",
          "required": true
      }
    }
  }
@metasection
Copy link
Author

Just tested. Issue persists. Are you tackling these types of issues? If you don't have time, I will take a crack at it when time permits. Please let me know.

@metasection
Copy link
Author

Any feedback?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant