typespec icon indicating copy to clipboard operation
typespec copied to clipboard

Emitters need concrete syntax ordering from the TypeSpec file to be available so they can maintain that order in output files.

Open gareth-a-jones opened this issue 2 years ago • 4 comments

Discussed in https://github.com/microsoft/typespec/discussions/3261

For our workload, grouping and ordering of input is important, whether in a single file or spread across multiple imported files.

As we're in the middle of a long-term migration, being able to diff manually created output against typespec-generated-output and have a rational experience is key to building confidence with our customers.

Today we're not able to replicate input ordering in output, meaning every diff is an adventure in trying to convince yourself that semantically meaningful changes haven't crept in in the transition to TypeSpec.

This is holding up our ability to migrate at scale, as the manual verification tax is so high.

gareth-a-jones avatar May 20 '24 23:05 gareth-a-jones

@garethj-msft We were looking at this - is this specifically about a particular output, like OpenAPI3, about the order of processing each type in an emitter, or something else?

We have some solutions we have used for getting a canonical ordering in output types like OpenAPI and wonder if this might resolve your issue

markcowl avatar Aug 14 '24 21:08 markcowl

@markcowl It's about being able to map TSP ordering to output format ordering primarily in our CSDL emitter.

So a canonical order doesn't much help (that's effectively what we have today - ordering by meta-type)

What we need is if the TSP author reorders model B before model A then that needs to be the order of the corresponding Entity elements in the output CSDL, regardless of semantic relationships between A and B.

gareth-a-jones avatar Sep 19 '24 07:09 gareth-a-jones

@markcowl , Oh, I think you put it in a very old milestone 🦞

gareth-a-jones avatar Sep 19 '24 07:09 gareth-a-jones

We have some solutions we have used for getting a canonical ordering in output types like OpenAPI and wonder if this might resolve your issue

@markcowl I ran in to same problem today. my .tsp output in openapi3 doesn't match the ordering I wrote in tsp interface. what is the solution ?

MrBns avatar Mar 02 '26 22:03 MrBns