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

oav generate-examples on typespec with byte generates invalid examples #1016

Open
scbedd opened this issue Oct 24, 2023 · 0 comments
Open

oav generate-examples on typespec with byte generates invalid examples #1016

scbedd opened this issue Oct 24, 2023 · 0 comments

Comments

@scbedd
Copy link
Member

scbedd commented Oct 24, 2023

Discovered in this typespec generated PR

User entered oav generate-examples ./generated.json using the generated.json spec present in above PR.

Here is an example of the specific place in the generated example that was problematic.

Prior to user manually correcting with "<your image bytes>" these were generated with values that failed validation. Specifically:

{
    message: [ {

        code: 'INVALID_TYPE',
        message: 'Expected type string but found type object',
        schemaUrl: '.\\ImageAnalysis.json',
        exampleUrl: 'examples\\SegmentFromStream_MaximumSet_Gen.json',
        schemaPosition: {
            line: 139, column: 23
        }

        ,
        schemaJsonPath: '#/properties/body/type',
        examplePosition: {
            line: 7, column: 21
        }

        ,
        exampleJsonPath: '$parameters.imageContent',
        severity: 0,
        source: 'request',
        operationId: 'SegmentFromStream',
        [Symbol(level)]: 'error',
        [Symbol(message)]: '{"code":"INVALID_TYPE","exampleJsonPath":"$parameters.imageContent","examplePosition":{"column":21,"line":7},"exampleUrl":"examples\\\\SegmentFromStream_MaximumSet_Gen.json","level":"error","message":"Expected type string but found type object","operationId":"SegmentFromStream","schemaJsonPath":"#/properties/body/type","schemaPosition":{"column":23,"line":139},"schemaUrl":".\\\\ImageAnalysis.json","severity":0,"source":"request"}'
    }

    level: '\x1B[31merror\x1B[39m'
}

This is because the imageContent was generating with erroneous value {}. User correct {} to "<your bytes here>" and example passed validation.

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