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

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

Open
point-source opened this issue Sep 29, 2020 · 0 comments · May be fixed by #898
Open

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

point-source opened this issue Sep 29, 2020 · 0 comments · May be fixed by #898

Comments

@point-source
Copy link

point-source commented Sep 29, 2020

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant