Tarantool now has a built-in type UUID.
How to insert a record and pass this field using https://github.com/tarantool/go-tarantool?
For now I have this:
Tuple field 1 type does not match one required by operation: expected uuid (0x17)
when trying to insert UUID as a string
"github.com/satori/go.uuid"
...
var (
Tarantool *tarantool.Connection
)
...
Tarantool.Insert("log", []interface{}{
uuid.NewV4().String(),
...
Index:
index:
0: &0
unique: true
parts:
- type: uuid
is_nullable: false
fieldno: 1
id: 0
space_id: 513
type: HASH
name: primary
primary: *0
it is a fresh feature that is not supported in official go driver. You may track implementation progress and open discussions here
Related
Can I validate both
name: "range_1"
step: 1
start: 0
stop: 10
and
name: "range_2"
step: 1
center: 5
span: 5
with something like
properties:
name:
type: "string"
stop:
type: number
oneOf:
- start:
type: number
step:
type: number
- center:
type: number
span:
type: number
For now I am using jsonschema in Python, but it complains jsonschema.exceptions.SchemaError: <the array in oneOf> is not of type 'object', 'boolean'.
Validating against name and step only or validating against all possible keys apparently works but they both seem sub-optimal for me.
You need to move the oneOf keyword out of the properties object as everything in the properties object is interpreted as an expected value in your data.
Additionally, it makes sense to add an required property to make the values mandatory. Finally, if you want to make sure that no other values are excepted, you can use additionalProperties: false. Note though, that you have to repeat the "parent" properties in the oneOf schemas again. For further reading I recommend this example.
Put all together, you could use the following schema (see live example here):
---
properties:
name:
type: string
step:
type: number
oneOf:
- properties:
name: true
step: true
start:
type: number
stop:
type: number
required:
- start
- stop
additionalProperties: false
- properties:
name: true
step: true
center:
type: number
span:
type: number
required:
- center
- span
additionalProperties: false
I have a swagger.yaml file having a lot of APIs. I would like to remove all the parameters with the name of user-id from all of the APIs. Also, there are examples and x-examples which are irrelevant for my use-case that I would like to be removed.
I have been experimenting with openapi-filter. However, for it to work I'll have to add a special tag to the parameters and it won't work for examples. I could also be using it incorrectly.
parameters:
- name: action-id
in: path
description: Action ID which needs to be failed
required: true
type: integer
format: int64
x-example: 1
- name: action-category-number
in: path
description: Action category number which needs to be failed
required: true
type: integer
format: int64
example: 2
- name: user-id
in: header
description: User under which the action exists
required: true
type: integer
format: int32
x-example: 1
Expected output:
parameters:
- name: action-id
in: path
description: Action ID which needs to be failed
required: true
type: integer
format: int64
- name: action-category-number
in: path
description: Action category number which needs to be failed
required: true
type: integer
format: int64
I have an AWS Kinesis Firehose that sends data to Redshift via S3.
I'd like to have newlines appear between records sent using put_record_batch. Currently my code looks like this:
records = [{ id: 1, value: "foo" }, { id: 2, value: "bar" }]
Aws::Firehose::Client.new(
region: "us-east-1"
).put_record_batch({
delivery_stream_name: "my_firehose",
records: records
)
The records that end up in S3 look like this:
{"id":1,"value":"foo"}{"id":2,"value":"bar"}
I would like for the S3 files to instead look like this:
{"id":1,"value":"foo"}
{"id":2,"value":"bar"}
This will make it easier to manually parse the files when necessary (for example, if we need to debug why data isn't making it from S3 to Redshift).
The solution for put_record is simple: you convert the data to JSON and add a newline:
record = { id: 1, value: "foo" }
Aws::Firehose::Client.new(
region: "us-east-1"
).put_record({
delivery_stream_name: "my_firehose",
data: record.to_json << "\n"
)
I tried to do something similar with put_record_batch:
records = [{ id: 1, value: "foo"}, { id: 2, value: "bar" }]
json_records = records.map { |record| record.to_json << "\n" }
Aws::Firehose::Client.new(
region: "us-east-1"
).put_record_batch({
delivery_stream_name: "my_firehose",
records: json_records
)
But this resulted in the error:
ArgumentError: parameter validator found 2 errors:
- expected params[:records][0] to be a hash, got value "{\"id\":1,\"value\":\"foo\"}\n" (class: String) instead.
- expected params[:records][1] to be a hash, got value "{\"id\":2,\"value\":\"bar\"}\n" (class: String) instead.
from /mnt/istore/apps/my_app/shared/bundle/ruby/2.7.0/gems/aws-sdk-core-3.89.1/lib/aws-sdk-core/param_validator.rb:33:in `validate!'
So it seems that we're required to send a hash.
The documentation for put_record_batch says:
Kinesis Data Firehose buffers records before delivering them to the destination. To disambiguate the data blobs at the destination, a common solution is to use delimiters in the data, such as a newline (\n) or some other character unique within the data. This allows the consumer application to parse individual data items when reading the data from the destination.
How do I do this?
I'm using version 1.26.0 of the aws-sdk-firehose gem.
I think the problem was that I was leaving off the data key when using put_record_batch. This seems to work:
records = [{ id: 1, value: "foo"}, { id: 2, value: "bar" }]
json_records = records.map do |record|
# Previously this line was `record.to_json << "\n"`
{ data: record.to_json << "\n" }
end
Aws::Firehose::Client.new(
region: "us-east-1"
).put_record_batch({
delivery_stream_name: "my_firehose",
records: json_records
)
I'm using Swagger YAML file for producing interactive documentation on apiary.io.
I've noticed a strange issue where if I specify a default value 0 for an integer, the interactive documentation doesn't render it at all and shows "null" as default value instead. If i specify a non-zero value it renders perfectly fine.
Example :
- name: pageNumber
in: query
description: The page number, starting at 0.
required: true
type: number
format: int32
default: 0
- name: pageSize
in: query
description: The page size (max number of entities that are displayed in the
response).
required: true
type: integer
format: int32
default: 20
Appends ?pageNumber=&pageSize=20 to my path whereas it should've added ?pageNumber=0&pageSize=20 instead.
When I add a non-zero as follows :
- name: pageNumber
in: query
description: The page number, starting at 0.
required: true
type: number
format: int32
default: 1
- name: pageSize
in: query
description: The page size (max number of entities that are displayed in the
response).
required: true
type: integer
format: int32
default: 20
This is rendered fine, and appends ?pageNumber=1&pageSize=20 as expected.
Helen's comment resolved my issue.
When documenting using YAML on apiary.io, for setting default/initial values in the interactive documentation, x-example needs to be used. Now, the following works as expected :
- name: pageNumber
in: query
description: The page number, starting at 0.
required: true
type: number
format: int32
x-example: 0
- name: pageSize
in: query
description: The page size (max number of entities that are displayed in the
response).
required: true
type: integer
format: int32
x-example: 20
Successfully gets rendered as ?pageNumber=0&pageSize=20
This question already has answers here:
Swagger: How to have a property reference a model in OpenAPI 2.0 (i.e. nest the models)?
(2 answers)
Closed 2 years ago.
I created a definition called Product and another called Text (see code).
On parameters of paths I can not use the type Text created in definitions. On the definition Product I have a property called message and I want that property to be the type Text too.
(...)
paths:
/products:
get:
summary: Product Types
description: |
Description text
parameters:
- name: latitude
in: query
description: Latitude component of location.
required: true
### The type Text was not found here
type: Text ### The type Text was not found here
(...)
definitions:
Product:
properties:
message:
### The type Text was not found here
type: Text ### Compilation Error in this line ####
name:
type: string
description: Data description.
Text:
properties:
code:
type: string
But this error occurs:
Swagger Error:
Data does not match any schemas from 'anyOf'.
How can I reference the type Text on the type Product?
Please use $ref instead. Here is an example
type: object
required:
- name
properties:
name:
type: string
address:
$ref: '#/definitions/Address'
age:
type: integer
format: int32
minimum: 0
Ref: https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#simple-model