Skip to content
This repository was archived by the owner on Mar 18, 2021. It is now read-only.
This repository was archived by the owner on Mar 18, 2021. It is now read-only.

Openapi generator (wrongly?) includes private ORM fields #897

Description

@point-source

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions