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

CreateSchema method #74

Closed
kompl opened this issue Apr 11, 2022 · 4 comments
Closed

CreateSchema method #74

kompl opened this issue Apr 11, 2022 · 4 comments

Comments

@kompl
Copy link
Contributor

kompl commented Apr 11, 2022

The method returns the latest version of the schema, but the schema registry behaves differently: it compares the schemas with the existing ones, and if it doesn't find it, it creates a new schema. In this case, the answer will be correct.
But if it finds a match, then the post request will return the id of the existing schema, in which case the answer will be incorrect, since the existing schema will not necessarily be the last one.

cp-schema-registry:7.0.1

@kompl
Copy link
Contributor Author

kompl commented Apr 11, 2022

Request:

curl --location --request POST '0.0.0.0:8081/subjects/charges/versions' \
--header 'Content-Type: application/vnd.schemaregistry.v1+json' \
--data-raw '{
    "schema": "{\"type\":\"record\",\"name\":\"ChargeMessage\",\"fields\":[{\"name\":\"MessageTypeId\",\"type\":\"int\"},{\"name\":\"MessageTypeCode\",\"type\":\"string\"},{\"name\":\"Version\",\"type\":\"int\"},{\"name\":\"CreatedAt\",\"type\":\"string\",\"logicalType\":\"date\"},{\"name\":\"Payload\",\"type\":{\"type\":\"record\",\"name\":\"Payload\",\"fields\":[{\"name\":\"Charge\",\"type\":{\"type\":\"record\",\"name\":\"Charge\",\"fields\":[{\"name\":\"ChargeLogId\",\"type\":\"int\"},{\"name\":\"ChargeLogLineId\",\"type\":\"long\"},{\"name\":\"ChargeLogLineIdq\",\"type\":\"long\"},{\"name\":\"ChangeBalanceTypejjhkId\",\"type\":\"string\"}]}}]}}]}"
}'

Response:

{
    "id": 1
}

Request:

curl --location --request GET '0.0.0.0:8081/subjects/charges/versions/latest' \
--header 'Content-Type: application/vnd.schemaregistry.v1+json'

Response:

{
    "subject": "charges",
    "version": 8,
    "id": 8,
    "schema": "{\"type\":\"record\",\"name\":\"ChargeMessage\",\"fields\":[{\"name\":\"MessageTypeId\",\"type\":\"int\"},{\"name\":\"MessageTypeCode\",\"type\":\"string\"},{\"name\":\"Version\",\"type\":\"int\"},{\"name\":\"CreatedAt\",\"type\":\"string\",\"logicalType\":\"date\"},{\"name\":\"Payload\",\"type\":{\"type\":\"record\",\"name\":\"Payload\",\"fields\":[]}}]}"
}

@kompl
Copy link
Contributor Author

kompl commented Apr 11, 2022

#75

@kompl kompl closed this as completed Apr 11, 2022
@kompl kompl reopened this Apr 11, 2022
@riferrei
Copy link
Owner

Your PR was merged and included in the v0.5.2 release. Thanks 🙏🏻

@kompl
Copy link
Contributor Author

kompl commented Apr 12, 2022

Your PR was merged and included in the v0.5.2 release. Thanks 🙏🏻

Thanks 🙏🏻

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

2 participants