Files
codegenerator/codegenerator
Gorka Eguileor 87ff2fe25e YAML version support
When exporting OpenAPI in YAML format we are exporting in YAML version
1.2, which is the latest. The problem with that is that there are tools
that use the PyYAML [1] python package to read these files, and that
package only supports YAML v1.1, which will lead to reading things
incorrectly.

An example is with booleans.

In v1.1 a lot of values are considered as booleans (case insensitive):
true, false, 1, 0, off, on, no, yes... But in v1.2 only true and false
are considered booleans, so the others don't need to be quoted.

As an example we were generating something like this:

```
        os_hypervisors_with_servers:
          in: query
          name: with_servers
          schema:
            type:
              - boolean
              - string
            enum:
              - true
              - 'True'
              - 'TRUE'
              - 'true'
              - '1'
              - ON
              - On
              - on
              - YES
              - Yes
              - yes
              - false
              - 'False'
              - 'FALSE'
              - 'false'
              - '0'
              - OFF
              - Off
              - off
              - NO
              - No
              - no
          x-openstack:
            min-ver: '2.53'
```

Which is incorrectly interpreted by PyYAML like this:

```
            enum:
              - true
              - 'True'
              - 'TRUE'
              - 'true'
              - '1'
              - true
              - true
              - true
              - true
              - true
              - true
              - false
              - 'False'
              - 'FALSE'
              - 'false'
              - '0'
              - false
              - false
              - false
              - false
              - false
              - false ```
```

To fix this we enable our tool to output the specs in v1.1 with a new
parameter `--yaml-version` so that when it's set to 1.1 it will quote
all booleans that in v1.1 could be misinterpreted.

[1]: https://pypi.org/project/PyYAML/

Change-Id: I7236f6a94ccb2e92a086c16895efa4dc557460c4
2025-06-05 18:52:44 +02:00
..
2025-05-19 15:56:50 +02:00
2025-04-24 13:28:19 +02:00
2025-06-05 18:52:44 +02:00
2024-03-06 10:07:54 +00:00
2024-09-24 10:37:52 +02:00
2024-09-19 09:00:54 +02:00
2025-06-05 18:52:44 +02:00
2024-09-19 09:00:54 +02:00
2025-05-23 15:58:34 +02:00
2025-03-04 15:08:31 +01:00
2024-09-24 10:37:52 +02:00
2025-04-17 14:41:11 +02:00
2025-04-17 14:41:11 +02:00
2025-04-17 14:41:11 +02:00
2025-05-30 18:29:17 +00:00