Skip to content

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

Open

Description

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

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions