Exemple #1
0
 def test_arbitrary_field_with_title(self):
     field = fields.Arbitrary(title='A title')
     self.assertFalse(field.required)
     self.assertEqual(field.__schema__, {
         'type': 'number',
         'title': 'A title'
     })
Exemple #2
0
 def test_arbitrary_field_with_min_max(self):
     field = fields.Arbitrary(min=0, max=5)
     self.assertEqual(field.__schema__, {
         'type': 'number',
         'minimum': 0,
         'maximum': 5
     })
Exemple #3
0
 def test_arbitrary_field_with_description(self):
     field = fields.Arbitrary(description='A description')
     self.assertFalse(field.required)
     self.assertEqual(field.__schema__, {
         'type': 'number',
         'description': 'A description'
     })
class StingerProxy(Resource):
    jsonSpec = api.model(
        'rpc', {
            'jsonrpc':
            fields.String(
                description='JSON-RPC Version', required=True, default="2.0"),
            'method':
            fields.String(description='Method for RPC server to execute',
                          required=True),
            'params':
            fields.Raw(
                description=
                'JSON object describing parameters for the requested method',
                required=False),
            'id':
            fields.Arbitrary(description='User-specified ID of the request',
                             required=True,
                             default=False)
        })

    @api.expect(jsonSpec)
    def post(self):
        return stingerRPC(request.json)
 def test_with_default(self):
     field = fields.Arbitrary(default=0.5)
     self.assertEqual(field.__schema__, {'type': 'number', 'default': 0.5})
 def test_defaults(self):
     field = fields.Arbitrary()
     self.assertFalse(field.required)
     self.assertEqual(field.__schema__, {'type': 'number'})
Exemple #7
0
 def test_arbitrary_field_with_readonly(self):
     field = fields.Arbitrary(readonly=True)
     self.assertEqual(field.__schema__, {
         'type': 'number',
         'readOnly': True
     })
Exemple #8
0
 def test_arbitrary_field_with_required(self):
     field = fields.Arbitrary(required=True)
     self.assertTrue(field.required)
     self.assertEqual(field.__schema__, {'type': 'number'})
Exemple #9
0
resume_content_parser.add_argument('content_type', type=str, required=True, help='The resume content type submitted. Currently supported: ' + ', '.join(SUPPORTED_INPUTS), location='form')

resume_content = api.model('ResumeContent', {
  'content'        : fields.String(required=True),
  'content_type'   : fields.String(required=True, enum=SUPPORTED_INPUTS),
})

SUPPORTED_VIEWS = ['kibana3']

resume_view_parser = api.parser()
resume_view_parser.add_argument('view',         type=str, required=True, help='The visual representation desired. Currently supported: ' + ', '.join(SUPPORTED_VIEWS), location='form')
resume_view_parser.add_argument('other_params', type=str, required=False, help='Other parameters depending on the view selected.', location='form')

resume_view = api.model('ResumeView', {
  'view'         : fields.String(required=True, enum=SUPPORTED_VIEWS),
  'other_params' : fields.Arbitrary(required=False)
})

@ns.route('/')
class Resume(Resource):

  @api.doc(parser=resume_parser)
  @api.marshal_with(resume, code=201)
  def post(self):
    return True

@ns.route('/<string:username>/content')
@api.doc(responses={201: 'Created', 404: 'Resume not found'}, params={'username': '******'})
class ResumeContent(Resource):

  @api.doc(parser=resume_content_parser)