Coder Social home page Coder Social logo

Comments (9)

morlenefisher avatar morlenefisher commented on May 31, 2024 2

@bombompb I used I used https://github.com/izumin5210/json-schema-parser to parse the schema. Produced the form ok for me with local $ref

from ngx-schema-form.

ebrehault avatar ebrehault commented on May 31, 2024 1

@GermisMc the default widget template mainly use the description (but some use title, see https://github.com/makinacorpus/angular2-schema-form/blob/master/src/defaultwidgets/radio/radio.widget.ts), but you are free to override their template and use {{ schema.title }} if you prefer.

from ngx-schema-form.

ebrehault avatar ebrehault commented on May 31, 2024

As our objective is to generate a form (and not just use a schema to manipulate some structured data), we had to extend JSON Schema so we can handle form-specific features (like field widget, help messages, fieldsets, etc.).
But we do want to support the standard as closely as possible.
Regarding title: as far as I know, there is no title attribute for fields, do you mean the schema's title?
Regarding self-reference: what use case do you imagine?

from ngx-schema-form.

bombompb avatar bombompb commented on May 31, 2024

An example of a self reference is a schema in which you have a definitions section containing Types, which you then use in the schema properties.

For example:

{
  "id": "http://schange.com/schemas/a5sharedconfigschema.json",
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "regions": {
      "type": "array",
      "minItems": 1,
      "items": {
            "$ref": "#/definitions/regionType"
      }
    }
  },
  "definitions": {
    "regionType": {
      "properties": {
        "tag": {
          "description": "Tag that uniquely identifies a given region",
          "type": "string"
        },
        "currency": {
          "description": "Three letter alphabetic code for the currency from ISO 4217 (XYZ)",
          "type": "string",
          "pattern": "[A-Z]{3}"
        }
      },
      "required": [
        "tag",
        "currency"
      ]
    }
  }
}

Note: this is a reference within the same schema file. We also would like to make use of references outside the schema file to allow re-use of type definitions.

from ngx-schema-form.

bombompb avatar bombompb commented on May 31, 2024

Any plans to add the $ref support to this component?

Besides usage of $ref in Schema, I am also having a use case where I would like to make use of $ref support in the Model json.

from ngx-schema-form.

fbessou avatar fbessou commented on May 31, 2024

Until it is implemented, you can resolve the $ref properties by compiling your schema with ZSchema:```

let zschema = new ZSchema({});
zschema.compileSchema(mySchema);
mySchema = zschema.getResolvedSchema(mySchema);

but note that $ref usage is often combined with allOf properties to add additional properties such as title, placeholder, etc... . But allOf is not yet supported. These two features will be added soon.

from ngx-schema-form.

bombompb avatar bombompb commented on May 31, 2024

ok, thanks for the answer. Going to test this solution soon.

from ngx-schema-form.

bombompb avatar bombompb commented on May 31, 2024

I tested the workaround with the example I posted before in this issue, and it does not work. The example I posted contains local references within the same json schema file. So for z-schema I suppose there is nothing to be resolved. Z-Schema resolving might only work for remote references. However, you end up in both scenarios with a schema containing $ref indicators which are not supported by angular2-schema-form.

from ngx-schema-form.

NiKlimenko avatar NiKlimenko commented on May 31, 2024

@ebrehault hello, what about schema's title? As I understand it, now only the description works, right? Are there any plans to add support "title" schema's property as it stated in the standard?

from ngx-schema-form.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.