Hi Team, Our intent : We have an interlock A that...
# pactflow
p
Hi Team, Our intent : We have an interlock A that sends us a KAFKA message. We have a contract with this interlock. Now we want to ensure that the data they are sending is valid. So we want to pull the schema from broker and do a schema validation in C# (Code Level) and based on the validation result move further with our usage of that message. Actual Quesiton : I wanted to check if it would be possible to fetch the schema of a particular contract from the Pact-Broker.
m
what schema are you referring to, exactly? If you have a contract test between the kafka producer and consumer, what are you trying to achieve additionally?
Perhaps you could share more about your current Pact setup, what is covered etc.? And perhaps a bit more about your intent beyond that
p
This is what we mean by schema validation. https://stackoverflow.com/questions/19544183/validate-json-against-json-schema-c-sharp
Copy code
void Main()
{
var schema = JsonSchema.Parse(
@"{
    'type': 'object',
    'properties': {
        'name': {'type':'string'},
        'hobbies': {'type': 'array'}
    },
    'additionalProperties': false
    }");

IsValid(JObject.Parse(
@"{
    'name': 'James',
    'hobbies': ['.NET', 'LOLCATS']
  }"), 
schema).Dump();

IsValid(JObject.Parse(
@"{
    'surname': 2,
    'hobbies': ['.NET', 'LOLCATS']
  }"), 
schema).Dump();

IsValid(JObject.Parse(
@"{
    'name': 2,
    'hobbies': ['.NET', 'LOLCATS']
  }"), 
schema).Dump();
}

public bool IsValid(JObject obj, JsonSchema schema)
{
    return obj.IsValid(schema);
}
We wanted to know if we could get that schema from Pact broker. Currently with your help we have implemented PactFlow SAAS in our org end to end and built contracts. Our CICD jobs are setup. We are exploring some additional usage of pactflow right now.
m
Right, but PactFlow doesn’t store schemas - are you asking if it could store schemas? Or are you expecting that to be part of the usual contract test? I guess I’m just confused about the ask 😅
p
I was hoping that would be a part of current scenario in contract test. But guess not.. Let me take some time and see if I can form a better question
m
Schemas are altogether different from Pact tests, but some people understandably conflate schemas with contracts.