stablekernel/aqueduct

Openapi generator (wrongly?) includes private ORM fields

point-source opened this issue · 0 comments

I have some ORMs with private fields that do not get serialized but are used internally. Despite not being exposed on any endpoint, the openapi generator includes these fields in the openapi json spec. Using the aqueduct "db" template as an example:

My model (with a non-serialized private field called _myPrivateField):

class Model extends ManagedObject<_Model> implements _Model {
  @override
  void willInsert() {
    createdAt = DateTime.now().toUtc();
  }
}

class _Model {
  @primaryKey
  int id;

  @Column(indexed: true)
  String name;

  DateTime createdAt;

  @Column(nullable: true)
  String _myPrivateField;
}

Generated Openapi JSON:

"components": {
        "schemas": {
            "Model": {
                "title": "Model",
                "type": "object",
                "properties": {
                    "id": {
                        "title": "id",
                        "type": "integer",
                        "description": "This is the primary identifier for this object.\n",
                        "nullable": false
                    },
                    "name": {
                        "title": "name",
                        "type": "string",
                        "nullable": false
                    },
                    "createdAt": {
                        "title": "createdAt",
                        "type": "string",
                        "format": "date-time",
                        "nullable": false
                    },
                    "_myPrivateField": {
                        "title": "_myPrivateField",
                        "type": "string",
                        "nullable": true
                    }
                },
                "description": ""
            }
        },

How can I tell the generator to ignore private fields?

Aqueduct version: 4.0.0-b1
Dart version: 2.9.1-stable