OpenAPI-Specification icon indicating copy to clipboard operation
OpenAPI-Specification copied to clipboard

Add top level XML code generation hints

Open silkentrance opened this issue 7 years ago • 2 comments

Having to always denote the same xml properties over and over again, namely the prefix and the namespace on properties and data types alike, one should instead be able to add an xml property at the top level, e.g.

xml:
  namespace: 'foo:bar:v1'
  prefix: 'fbv1'
components:
  ...

This then would act as the default for all data types and properties and also items of properties of type array.

This will make things much easier for us.

In the future, this could be extended so that one could have multiple NSURLs and associated prefixes and just reference these prefixes from xml code generation hints at the data type level or property level, e.g.

xml:
  default:
    namespace: 'foo:v1'
  fbv1:
    namespace: 'foo:bar:v1'
  fbv1add:
    namespace: 'foo:bar:v1-additions'
components:
  Foobar:
    xml:
      prefix: 'fbv1add'
  Barfoo:
    xml:
      prefix: 'fbv1'
  Foo:
    // uses default namespace

The code generator could then look up the prefix from the top level xml code generation hints and fill in the gaps.

silkentrance avatar Aug 03 '18 20:08 silkentrance

Could this use case now be served by use of an Overlay?

lornajane avatar May 15 '25 18:05 lornajane

@lornajane I think that would be a good use of Overlays. I was looking at this a few days ago and realized that trying to solve it now would add another implicit lookup like what we do for discriminator and security requirements, and those have been problematic. An overlay would avoid that problem- I assume it would work by just selecting all XML Objects and adding the namespace and prefix fields, or selecting all XML Objects with a particular prefix field and adding namespace?

handrews avatar May 15 '25 18:05 handrews