简体   繁体   中英

Reading yaml file with refrence in python

demo.yaml

content:
        application/json:
          schema:
            title: YamlTitle
            type: object
            properties:
              name:
                "$ref": "definitions.yaml#/name"
            required:
              - data

definitions.yaml File data

  name:
    type: string
    minLength: 10
    example: GANESH

I want to read yaml file with its refrence data.

Output result = {'content': {'application/json': {'schema': {'title': 'YamlTitle', 'type': 'object', 'properties': {'name': {'type': 'string', 'minLength': 10, 'example': 'GANESH'}}, 'required': ['name']}}}}

You can implement it using a custom constructor & yaml loader where you add an YAML instruction that will do the trick.

Check https://davidchall.github.io/yaml-includes.html for example

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM